Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2023-01-30 05:12:55
Exec Total Coverage
Lines: 11127 17017 65.4%
Functions: 238 317 75.1%
Branches: 9423 19728 47.8%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #ifndef __GTHREAD_HIDE_WIN32API
16 #define __GTHREAD_HIDE_WIN32API 1
17
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 #endif //prevent indirectly including windows.h
18
19 #include "precompiled.h" //always first
20
21 #include <string.h>
22 #include <set>
23 #include <stdio.h>
24
25 #include "hero.h"
26 #include "guys.h"
27 #include "subscr.h"
28 #include "zc_subscr.h"
29 #include "decorations.h"
30 #include "gamedata.h"
31 #include "zc_custom.h"
32 #include "title.h"
33 #include "ffscript.h"
34 #include "drawing.h"
35 #include "combos.h"
36 #include "base/zc_math.h"
37 #include "user_object.h"
38 #include "slopes.h"
39 extern FFScript FFCore;
40 extern word combo_doscript[176];
41 extern byte itemscriptInitialised[256];
42 extern HeroClass Hero;
43 extern ZModule zcm;
44 extern zcmodule moduledata;
45 extern refInfo playerScriptData;
46 #include "zscriptversion.h"
47 #include "particles.h"
48 #include <fmt/format.h>
49
50 extern refInfo itemScriptData[256];
51 extern refInfo itemCollectScriptData[256];
52 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
53 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
54 extern refInfo *ri; //= NULL;
55 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
56 extern byte dmapscriptInitialised;
57 extern word item_doscript[256];
58 extern word item_collect_doscript[256];
59 extern portal* mirror_portal;
60 using std::set;
61
62 extern int32_t skipcont;
63
64 extern int32_t draw_screen_clip_rect_x1;
65 extern int32_t draw_screen_clip_rect_x2;
66 extern int32_t draw_screen_clip_rect_y1;
67 extern int32_t draw_screen_clip_rect_y2;
68 extern word global_wait;
69 extern bool player_waitdraw;
70 extern bool dmap_waitdraw;
71 extern bool passive_subscreen_waitdraw;
72 extern bool active_subscreen_waitdraw;
73
74 int32_t hero_count = -1;
75 int32_t hero_animation_speed = 1; //lower is faster animation
76 int32_t z3step = 2;
77 25 static zfix hero_newstep(1.5);
78 25 static zfix hero_newstep_diag(1.5);
79 bool did_scripta=false;
80 bool did_scriptb=false;
81 bool did_scriptl=false;
82 byte lshift = 0;
83 int32_t dowpn = -1;
84 int32_t directItem = -1; //Is set if Hero is currently using an item directly
85 int32_t directItemA = -1;
86 int32_t directItemB = -1;
87 int32_t directItemX = -1;
88 int32_t directItemY = -1;
89 int32_t directWpn = -1;
90 int32_t whistleitem=-1;
91 extern word g_doscript;
92 extern word player_doscript;
93 extern word dmap_doscript;
94 extern word passive_subscreen_doscript;
95 extern byte epilepsyFlashReduction;
96 extern int32_t script_hero_cset;
97
98 void playLevelMusic();
99
100 extern particle_list particles;
101
102 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
103
104 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
105 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
106 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
107 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
108
109 15 bool item_error()
110 {
111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(QMisc.miscsfx[sfxERROR])
112 sfx(QMisc.miscsfx[sfxERROR]);
113 15 return false;
114 }
115 11055975 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
116 {
117
2/2
✓ Branch 0 taken 12627 times.
✓ Branch 1 taken 11043348 times.
11055975 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
118 11043348 return false;
119 11055975 }
120
121 3690848 static inline bool platform_fallthrough(bool doslopecheck = true)
122 {
123
5/6
✓ Branch 0 taken 3690848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3684810 times.
✓ Branch 3 taken 6038 times.
✓ Branch 4 taken 3680293 times.
✓ Branch 5 taken 4517 times.
10158650 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
124
2/2
✓ Branch 0 taken 458517 times.
✓ Branch 1 taken 452479 times.
3690848 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
125
6/6
✓ Branch 0 taken 2778403 times.
✓ Branch 1 taken 3236920 times.
✓ Branch 2 taken 339528 times.
✓ Branch 3 taken 3349871 times.
✓ Branch 4 taken 312157 times.
✓ Branch 5 taken 27371 times.
910996 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
126 }
127
128 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
129 {
130 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
131 if(slopesmisc == 2) return false;
132 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
133 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
134 if (platform_fallthrough() && !ignoreFallthrough) return false;
135 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
136 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
137 return true;
138 return false;
139 }
140
141 5692806 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
142 {
143
4/4
✓ Branch 0 taken 1805589 times.
✓ Branch 1 taken 3887217 times.
✓ Branch 2 taken 1774659 times.
✓ Branch 3 taken 30930 times.
5692806 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
144
2/2
✓ Branch 0 taken 127017 times.
✓ Branch 1 taken 5534859 times.
5661876 if(slopesmisc == 2) return false;
145
4/4
✓ Branch 0 taken 3810621 times.
✓ Branch 1 taken 1724238 times.
✓ Branch 2 taken 119243 times.
✓ Branch 3 taken 3691378 times.
5534859 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
146
6/6
✓ Branch 0 taken 14819 times.
✓ Branch 1 taken 3676559 times.
✓ Branch 2 taken 798 times.
✓ Branch 3 taken 14021 times.
✓ Branch 4 taken 268 times.
✓ Branch 5 taken 530 times.
3691378 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
147
4/4
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 3689360 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 1278 times.
3690848 if (platform_fallthrough() && !ignoreFallthrough) return false;
148
4/4
✓ Branch 0 taken 749105 times.
✓ Branch 1 taken 2940465 times.
✓ Branch 2 taken 747875 times.
✓ Branch 3 taken 1230 times.
3689570 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
149
6/6
✓ Branch 0 taken 889013 times.
✓ Branch 1 taken 2799327 times.
✓ Branch 2 taken 880259 times.
✓ Branch 3 taken 8754 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 880246 times.
3688340 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
150 8767 return true;
151 3679573 return false;
152 5692806 }
153
154
155 10556828 bool usingActiveShield(int32_t itmid)
156 {
157
2/2
✓ Branch 0 taken 8836017 times.
✓ Branch 1 taken 1720811 times.
10556828 switch(Hero.action) //filter allowed actions
158 {
159 case none: case walking: case rafting:
160 case gothit: case swimhit:
161 8836017 break;
162 1720811 default: return false;
163 }
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8836017 times.
8836017 if(itmid < 0)
165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8836017 times.
8836017 itmid = (Hero.active_shield_id < 0
166 8836017 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
167
2/2
✓ Branch 0 taken 7507913 times.
✓ Branch 1 taken 1328104 times.
8836017 if(itmid < 0) return false;
168
1/2
✓ Branch 0 taken 7507913 times.
✗ Branch 1 not taken.
7507913 if(!checkitem_jinx(itmid)) return false;
169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7507913 times.
7507913 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
170 if(!isItmPressed(itmid)) return false;
171 return (checkbunny(itmid) && checkmagiccost(itmid));
172 10556828 }
173 6527274 int32_t getCurrentShield(bool requireActive)
174 {
175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6527274 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6527274 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
176 return Hero.active_shield_id;
177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6527274 times.
6527274 if(!requireActive) return current_item_id(itype_shield);
178 return -1;
179 6527274 }
180 81914 int32_t getCurrentActiveShield()
181 {
182 81914 int32_t id = Hero.active_shield_id;
183
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 81914 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
81914 if(id > -1 && usingActiveShield(id))
184 return id;
185 81914 return -1;
186 81914 }
187 3628648 int32_t refreshActiveShield()
188 {
189 3628648 int32_t id = -1;
190
2/2
✓ Branch 0 taken 3504949 times.
✓ Branch 1 taken 123699 times.
3628648 if(DrunkcBbtn())
191 {
192 123699 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123699 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123699 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
194 {
195 id = Bwpn&0xFFF;
196 }
197 123699 }
198
3/4
✓ Branch 0 taken 3628648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3191471 times.
✓ Branch 3 taken 437177 times.
3628648 if(id < 0 && DrunkcAbtn())
199 {
200 437177 itemdata const& dat = itemsbuf[Awpn&0xFFF];
201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 437177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
437177 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
202 {
203 id = Awpn&0xFFF;
204 }
205 437177 }
206
3/4
✓ Branch 0 taken 3628648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3628627 times.
✓ Branch 3 taken 21 times.
3628648 if(id < 0 && DrunkcEx1btn())
207 {
208 21 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
210 {
211 id = Xwpn&0xFFF;
212 }
213 21 }
214
3/4
✓ Branch 0 taken 3628648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3627535 times.
✓ Branch 3 taken 1113 times.
3628648 if(id < 0 && DrunkcEx2btn())
215 {
216 1113 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1113 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1113 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
218 {
219 id = Ywpn&0xFFF;
220 }
221 1113 }
222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3628648 times.
3628648 if(!usingActiveShield(id))
223 3628648 return -1;
224 return id;
225 3628648 }
226 static bool is_immobile()
227 {
228 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
229 return false;
230 zfix rate(Hero.steprate);
231 int32_t shieldid = getCurrentActiveShield();
232 if(shieldid > -1)
233 {
234 itemdata const& shield = itemsbuf[shieldid];
235 if(shield.flags & ITEM_FLAG10) //Change Speed flag
236 {
237 zfix perc = shield.misc7;
238 perc /= 100;
239 if(perc < 0)
240 perc = (perc*-1)+1;
241 rate = (rate * perc) + shield.misc8;
242 }
243 }
244 return rate != 0;
245 }
246
247 3812849 bool HeroClass::isStanding(bool forJump)
248 {
249
11/14
✓ Branch 0 taken 3809412 times.
✓ Branch 1 taken 3437 times.
✓ Branch 2 taken 3809412 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 266567 times.
✓ Branch 5 taken 3542845 times.
✓ Branch 6 taken 129948 times.
✓ Branch 7 taken 136619 times.
✓ Branch 8 taken 129948 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 129948 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 428 times.
✓ Branch 13 taken 129520 times.
3812849 bool st = (z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !ladderx && !laddery && !getOnSideviewLadder()) && hoverclk==0);
250
2/2
✓ Branch 0 taken 3679892 times.
✓ Branch 1 taken 132957 times.
3812849 if(!st) return false;
251 3679892 int32_t val = check_pitslide();
252
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 3679668 times.
3679892 if(val == -2) return false;
253
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3679657 times.
3679668 if(val == -1) return true;
254 11 return forJump;
255 3812849 }
256 14929 bool HeroClass::isLifting()
257 {
258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14929 times.
14929 if(lift_wpn) return true;
259 14929 return false;
260 14929 }
261
262 24249 void HeroClass::set_respawn_point(bool setwarp)
263 {
264
2/2
✓ Branch 0 taken 19731 times.
✓ Branch 1 taken 4518 times.
24249 if(setwarp)
265 {
266 4518 warpx = x;
267 4518 warpy = y;
268 4518 raftwarpx = x;
269 4518 raftwarpy = y;
270 4518 }
271
2/2
✓ Branch 0 taken 9985 times.
✓ Branch 1 taken 14264 times.
24249 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
272 {
273
2/2
✓ Branch 0 taken 14090 times.
✓ Branch 1 taken 174 times.
14264 switch(action)
274 {
275 case none: case walking:
276 14090 break;
277 default:
278 174 return; //Not a 'safe action'
279 }
280
3/6
✓ Branch 0 taken 14090 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14090 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14090 times.
14090 if(z > 0 || fakez > 0 || hoverclk) return; //in air
281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14090 times.
14090 if(check_pitslide(true) != -1) return; //On a pit
282
283 { //Check water
284 14090 int32_t water = 0;
285 14090 int32_t types[4] = {0};
286 14090 int32_t x1 = x+4, x2 = x+11,
287 14090 y1 = y+9, y2 = y+15;
288
1/2
✓ Branch 0 taken 14090 times.
✗ Branch 1 not taken.
14090 if (get_bit(quest_rules, qr_SMARTER_WATER))
289 {
290
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 14069 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14092 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
291
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 19 times.
21 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
292
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
293 2 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
294 14090 }
295 else
296 {
297 types[0] = COMBOTYPE(x1,y1);
298
299 if(MAPFFCOMBO(x1,y1))
300 types[0] = FFCOMBOTYPE(x1,y1);
301
302 types[1] = COMBOTYPE(x1,y2);
303
304 if(MAPFFCOMBO(x1,y2))
305 types[1] = FFCOMBOTYPE(x1,y2);
306
307 types[2] = COMBOTYPE(x2,y1);
308
309 if(MAPFFCOMBO(x2,y1))
310 types[2] = FFCOMBOTYPE(x2,y1);
311
312 types[3] = COMBOTYPE(x2,y2);
313
314 if(MAPFFCOMBO(x2,y2))
315 types[3] = FFCOMBOTYPE(x2,y2);
316
317 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
318 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
319 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
320
321 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
322 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
323 water = typec;
324 }
325
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 14088 times.
14090 if(water > 0)
326 {
327 2 return;
328 }
329 } //End check water
330
331 70440 int poses[4] = {
332 14088 COMBOPOS(x,y+(bigHitbox?0:8)),
333 14088 COMBOPOS(x,y+15),
334 14088 COMBOPOS(x+15,y+(bigHitbox?0:8)),
335 14088 COMBOPOS(x+15,y+15)
336 };
337
2/2
✓ Branch 0 taken 56352 times.
✓ Branch 1 taken 14088 times.
70440 for(auto pos : poses)
338 {
339
1/2
✓ Branch 0 taken 56352 times.
✗ Branch 1 not taken.
56352 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
340 return;
341 }
342 14088 }
343 24073 respawn_x = x;
344 24073 respawn_y = y;
345 24073 respawn_scr = currscr;
346 24073 respawn_dmap = currdmap;
347 24249 }
348
349 14 void HeroClass::go_respawn_point()
350 {
351 14 x = respawn_x;
352 14 y = respawn_y;
353 14 can_mirror_portal = false; //incase entry is on a portal!
354 14 warpx=x;
355 14 warpy=y;
356 14 raftwarpx = x;
357 14 raftwarpy = y;
358 14 trySideviewLadder(); //Cling to ladder automatically
359
360
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
14 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
361 12 return; //No cross-screen return
362
363
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(currdmap != respawn_dmap || currscr != respawn_scr)
364 {
365 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
366 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
367 }
368 14 }
369
370 6237 void HeroClass::trySideviewLadder()
371 {
372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6237 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6237 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
373 setOnSideviewLadder(true);
374 6237 }
375
376 16394741 bool HeroClass::can_pitfall(bool ignore_hover)
377 {
378
26/30
✓ Branch 0 taken 15773661 times.
✓ Branch 1 taken 621080 times.
✓ Branch 2 taken 15722151 times.
✓ Branch 3 taken 51510 times.
✓ Branch 4 taken 15715613 times.
✓ Branch 5 taken 6538 times.
✓ Branch 6 taken 15715613 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15715593 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 15715593 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 15715593 times.
✓ Branch 14 taken 15708174 times.
✓ Branch 15 taken 7419 times.
✓ Branch 16 taken 15707307 times.
✓ Branch 17 taken 867 times.
✓ Branch 18 taken 15706793 times.
✓ Branch 19 taken 514 times.
✓ Branch 20 taken 15626553 times.
✓ Branch 21 taken 80240 times.
✓ Branch 22 taken 15397586 times.
✓ Branch 23 taken 228967 times.
✓ Branch 24 taken 15397306 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 15397306 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 2240 times.
✓ Branch 29 taken 15395066 times.
16394741 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
379 }
380
381 2107166 int32_t HeroClass::DrunkClock()
382 {
383 2107166 return drunkclk;
384 }
385 void HeroClass::setDrunkClock(int32_t newdrunkclk)
386 {
387 drunkclk=newdrunkclk;
388 }
389
390 int32_t HeroClass::StunClock()
391 {
392 return lstunclock;
393 }
394 void HeroClass::setStunClock(int32_t v)
395 {
396 lstunclock=v;
397 }
398
399 56023588 int32_t HeroClass::BunnyClock()
400 {
401 56023588 return lbunnyclock;
402 }
403 void HeroClass::setBunnyClock(int32_t v)
404 {
405 lbunnyclock=v;
406 }
407
408
9/18
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 25 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 25 times.
✗ Branch 17 not taken.
75 HeroClass::HeroClass() : sprite()
409 50 {
410 25 lift_wpn = nullptr;
411
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 init();
412 25 }
413
414 //2.6
415
416 //Stop the subscreen from falling. -Z
417
418 465 bool HeroClass::stopSubscreenFalling(){
419 465 return preventsubscreenfalling;
420 }
421
422 void HeroClass::stopSubscreenFalling(bool v){
423 preventsubscreenfalling = v;
424 }
425
426
427 //Set the button items by brute force
428
429 void HeroClass::setAButtonItem(int32_t itmslot){
430 game->awpn = itmslot;
431 }
432
433 void HeroClass::setBButtonItem(int32_t itmslot){
434 game->bwpn = itmslot;
435 }
436
437 3628965 void HeroClass::ClearhitHeroUIDs()
438 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
439 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
440 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
441 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
442 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
443 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
444 //clear it on the next frame, but that had the SAME outcome.
445 //Where and how can I clear a value at the end of every frame, so that:
446 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
447 // 2. FFCs can read it before Waitframe. --same.
448 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
449
2/2
✓ Branch 0 taken 29031720 times.
✓ Branch 1 taken 3628965 times.
32660685 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED_PLAYER; q++ )
450 {
451 /*
452 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
453 {
454 //Z_scripterrlog("frame is: %d\n", frame);
455 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
456 lastHitBy[q][0] = 0;
457 }
458 */
459 29031720 lastHitBy[q][0] = 0;
460 29031720 }
461 3628965 }
462
463 9038 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
464 {
465 9038 lastHitBy[type][0] = screen_index;
466 9038 }
467
468 2929 int32_t HeroClass::gethitHeroUID(int32_t type)
469 {
470 2929 return lastHitBy[type][0];
471 }
472
473 void HeroClass::set_defence(int32_t type, int32_t v)
474 {
475 defence[type] = v;
476 }
477
478 int32_t HeroClass::get_defence(int32_t type)
479 {
480 return defence[type];
481 }
482
483
484 //Set Hero;s hurt sfx
485 void HeroClass::setHurtSFX(int32_t sfx)
486 {
487 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
488 }
489 4660 int32_t HeroClass::getHurtSFX()
490 {
491 4660 return QMisc.miscsfx[sfxHURTPLAYER];
492 }
493
494 bool HeroClass::getDiagMove()
495 {
496 return diagonalMovement;
497 }
498 void HeroClass::setDiagMove(bool newdiag)
499 {
500 diagonalMovement=newdiag;
501 }
502 9024 bool HeroClass::getBigHitbox()
503 {
504 9024 return bigHitbox;
505 }
506 203 void HeroClass::setBigHitbox(bool newbigHitbox)
507 {
508 203 bigHitbox=newbigHitbox;
509 203 syofs = bigHitbox?0:8;
510 203 sysz_ofs = bigHitbox?0:-8;
511 203 }
512 5424 int32_t HeroClass::getStepRate()
513 {
514 5424 return steprate;
515 }
516 void HeroClass::setStepRate(int32_t newrate)
517 {
518 steprate = newrate;
519 }
520 int32_t HeroClass::getSwimUpRate()
521 {
522 return game->get_sideswim_up();
523 }
524 void HeroClass::setSwimUpRate(int32_t newrate)
525 {
526 game->set_sideswim_up(newrate);
527 }
528 int32_t HeroClass::getSwimSideRate()
529 {
530 return game->get_sideswim_side();
531 }
532 void HeroClass::setSwimSideRate(int32_t newrate)
533 {
534 game->set_sideswim_side(newrate);
535 }
536 int32_t HeroClass::getSwimDownRate()
537 {
538 return game->get_sideswim_down();
539 }
540 void HeroClass::setSwimDownRate(int32_t newrate)
541 {
542 game->set_sideswim_down(newrate);
543 }
544
545
546 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
547 2601033 void HeroClass::herostep()
548 {
549
2/2
✓ Branch 0 taken 2379272 times.
✓ Branch 1 taken 221761 times.
2601033 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
550 //need to run all global/hero/dmap scripts here?
551 2601033 }
552
553 25670 bool is_moving()
554 {
555
6/6
✓ Branch 0 taken 22246 times.
✓ Branch 1 taken 3424 times.
✓ Branch 2 taken 18121 times.
✓ Branch 3 taken 4125 times.
✓ Branch 4 taken 8185 times.
✓ Branch 5 taken 9936 times.
25670 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
556 }
557
558 // called by ALLOFF()
559 7195 void HeroClass::resetflags(bool all)
560 {
561 7195 refilling=REFILL_NONE;
562 7195 inwallm=false;
563 7195 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
564 7195 usecounts.clear();
565
566
4/4
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 7080 times.
7195 if(swordclk>0 || all)
567 {
568 115 swordclk=0;
569 115 verifyAWpn();
570 115 }
571
4/4
✓ Branch 0 taken 7187 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 7099 times.
7195 if(itemclk>0 || all)
572 96 itemclk=0;
573
574
2/2
✓ Branch 0 taken 7107 times.
✓ Branch 1 taken 88 times.
7195 if(all)
575 {
576 88 NayrusLoveShieldClk=0;
577
578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(nayruitem != -1)
579 {
580 stop_sfx(itemsbuf[nayruitem].usesound);
581 stop_sfx(itemsbuf[nayruitem].usesound+1);
582 }
583
584 88 nayruitem = -1;
585 88 hoverclk=jumping=0;
586 88 hoverflags = 0;
587 88 }
588 7195 damageovertimeclk = 0;
589 7195 newconveyorclk = 0;
590 7195 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
591
2/2
✓ Branch 0 taken 7195 times.
✓ Branch 1 taken 50365 times.
57560 for(auto q = 0; q < 7; ++q)
592 50365 hooked_undercombos[q] = -1;
593 7195 hopclk=0;
594 7195 hopdir=-1;
595 7195 attackclk=0;
596 7195 stomping=false;
597 7195 reset_swordcharge();
598 7195 diveclk=drownclk=drownCombo=0;
599 7195 action=none; FFCore.setHeroAction(none);
600 7195 conveyor_flags=0;
601 7195 magiccastclk=0;
602 7195 magicitem=-1;
603 7195 }
604
605 //Can use this for Hero->Stun. -Z
606 4652 void HeroClass::Freeze()
607 {
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652 times.
4652 if (action != inwind)
609 {
610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652 times.
4652 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
611 4652 else {action=freeze; FFCore.setHeroAction(freeze);}
612 // also cancel Hero's attack
613 4652 attackclk = 0;
614 4652 }
615 4652 }
616 647 void HeroClass::unfreeze()
617 {
618
3/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 365 times.
✗ Branch 3 not taken.
647 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 647 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
647 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
620 647 }
621
622 11 void HeroClass::Drown(int32_t state)
623 {
624 // Hero should never drown if the ladder is out
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(ladderx+laddery)
626 return;
627
628 11 drop_liftwpn();
629
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 switch(state)
630 {
631 case 1:
632 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
633 attackclk=0;
634 attack=wNone;
635 attackid=-1;
636 reset_swordcharge();
637 drownclk=64;
638 z=fakez=fall=fakefall=0;
639 break;
640
641
642 default:
643 {
644
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
645 11 else {action=drowning; FFCore.setHeroAction(drowning);}
646 11 attackclk=0;
647 11 attack=wNone;
648 11 attackid=-1;
649 11 reset_swordcharge();
650 11 drownclk=64;
651 11 z=fakez=fall=fakefall=0;
652 11 break;
653 }
654 }
655
656 11 }
657
658 455 void HeroClass::finishedmsg()
659 {
660 //these are to cancel out any keys that Hero may
661 //be pressing so he doesn't attack at the end of
662 //a message if he was scrolling through it quickly.
663 455 rAbtn();
664 455 rBbtn();
665 455 unfreeze();
666
667
3/4
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 439 times.
894 if(action == landhold1 ||
668
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 action == landhold2 ||
669
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 action == waterhold1 ||
670
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 action == waterhold2 ||
671
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 action == sidewaterhold1 ||
672 439 action == sidewaterhold2)
673 {
674 16 holdclk = 1;
675 16 }
676 455 }
677 28 void HeroClass::setEaten(int32_t i)
678 {
679 28 inlikelike=i;
680 28 }
681 25 int32_t HeroClass::getEaten()
682 {
683 25 return inlikelike;
684 }
685 12031964 zfix HeroClass::getX()
686 {
687 12031964 return x;
688 }
689 11451982 zfix HeroClass::getY()
690 {
691 11451982 return y;
692 }
693 25919826 zfix HeroClass::getZ()
694 {
695 25919826 return z;
696 }
697 17589449 zfix HeroClass::getFakeZ()
698 {
699 17589449 return fakez;
700 }
701 382611 zfix HeroClass::getFall()
702 {
703 382611 return fall;
704 }
705 zfix HeroClass::getFakeFall()
706 {
707 return fakefall;
708 }
709 zfix HeroClass::getXOfs()
710 {
711 return xofs;
712 }
713 zfix HeroClass::getYOfs()
714 {
715 return yofs;
716 }
717 void HeroClass::setXOfs(int32_t newxofs)
718 {
719 xofs=newxofs;
720 }
721 void HeroClass::setYOfs(int32_t newyofs)
722 {
723 yofs=newyofs;
724 }
725 int32_t HeroClass::getHXOfs()
726 {
727 return hxofs;
728 }
729 int32_t HeroClass::getHYOfs()
730 {
731 return hyofs;
732 }
733 int32_t HeroClass::getHXSz()
734 {
735 return hxsz;
736 }
737 int32_t HeroClass::getHYSz()
738 {
739 return hysz;
740 }
741 19264 zfix HeroClass::getClimbCoverX()
742 {
743 19264 return climb_cover_x;
744 }
745 19264 zfix HeroClass::getClimbCoverY()
746 {
747 19264 return climb_cover_y;
748 }
749 int32_t HeroClass::getLadderX()
750 {
751 return ladderx;
752 }
753 int32_t HeroClass::getLadderY()
754 {
755 return laddery;
756 }
757
758 36147 void HeroClass::setX(int32_t new_x)
759 {
760 36147 zfix dx=new_x-x;
761 36147 justmoved = 2;
762
1/2
✓ Branch 0 taken 36147 times.
✗ Branch 1 not taken.
36147 if(Lwpns.idFirst(wHookshot)>-1)
763 {
764 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
765 hs_startx+=(int32_t)dx;
766 }
767
768
1/2
✓ Branch 0 taken 36147 times.
✗ Branch 1 not taken.
36147 if(Lwpns.idFirst(wHSHandle)>-1)
769 {
770 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
771 }
772
773
1/2
✓ Branch 0 taken 36147 times.
✗ Branch 1 not taken.
36147 if(chainlinks.Count()>0)
774 {
775 for(int32_t j=0; j<chainlinks.Count(); j++)
776 {
777 chainlinks.spr(j)->x+=dx;
778 }
779 }
780
781 36147 x=new_x;
782
783 // A kludge
784
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 34058 times.
✓ Branch 2 taken 1464 times.
✓ Branch 3 taken 625 times.
36147 if(!diagonalMovement && dir<=down)
785 625 is_on_conveyor=true;
786 36147 }
787
788 51929 void HeroClass::setY(int32_t new_y)
789 {
790 51929 zfix dy=new_y-y;
791 51929 justmoved = 2;
792
1/2
✓ Branch 0 taken 51929 times.
✗ Branch 1 not taken.
51929 if(Lwpns.idFirst(wHookshot)>-1)
793 {
794 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
795 hs_starty+=(int32_t)dy;
796 }
797
798
1/2
✓ Branch 0 taken 51929 times.
✗ Branch 1 not taken.
51929 if(Lwpns.idFirst(wHSHandle)>-1)
799 {
800 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
801 }
802
803
1/2
✓ Branch 0 taken 51929 times.
✗ Branch 1 not taken.
51929 if(chainlinks.Count()>0)
804 {
805 for(int32_t j=0; j<chainlinks.Count(); j++)
806 {
807 chainlinks.spr(j)->y+=dy;
808 }
809 }
810
811 51929 y=new_y;
812
813 // A kludge
814
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 49840 times.
✓ Branch 2 taken 625 times.
✓ Branch 3 taken 1464 times.
51929 if(!diagonalMovement && dir>=left)
815 1464 is_on_conveyor=true;
816 51929 }
817
818 2 void HeroClass::setZ(int32_t new_z)
819 {
820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(isSideViewHero())
821 return;
822
823
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(z==0 && new_z > 0)
824 {
825
1/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch(action)
826 {
827 case swimming:
828 {
829 diveclk=0;
830 action=walking; FFCore.setHeroAction(walking);
831 break;
832 }
833
834 case waterhold1:
835 {
836 action=landhold1; FFCore.setHeroAction(landhold1);
837 break;
838 }
839
840 case waterhold2:
841 {
842 action=landhold2; FFCore.setHeroAction(landhold2);
843 break;
844 }
845
846 default:
847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(charging) //!DIMITODO: Let Hero jump while charging sword
848 {
849 reset_swordcharge();
850 attackclk=0;
851 }
852
853 2 break;
854 }
855 2 }
856
857
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 z=(new_z>0 ? new_z : 0);
858 2 }
859
860 void HeroClass::setFakeZ(int32_t new_z)
861 {
862 if(isSideViewHero())
863 return;
864
865 if(fakez==0 && new_z > 0)
866 {
867 switch(action)
868 {
869 case swimming:
870 {
871 diveclk=0;
872 action=walking; FFCore.setHeroAction(walking);
873 break;
874 }
875
876 case waterhold1:
877 {
878 action=landhold1; FFCore.setHeroAction(landhold1);
879 break;
880 }
881
882 case waterhold2:
883 {
884 action=landhold2; FFCore.setHeroAction(landhold2);
885 break;
886 }
887
888 default:
889 if(charging) //!DIMITODO: Let Hero jump while charging sword
890 {
891 reset_swordcharge();
892 attackclk=0;
893 }
894
895 break;
896 }
897 }
898
899 fakez=(new_z>0 ? new_z : 0);
900 }
901
902 1211 void HeroClass::setXfix(zfix new_x)
903 {
904 //Z_scripterrlog("setxdbl: %f\n",new_x);
905 1211 zfix dx=new_x-x;
906 1211 justmoved = 2;
907
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHookshot)>-1)
908 {
909 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
910 hs_startx+=(int32_t)dx;
911 }
912
913
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHSHandle)>-1)
914 {
915 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
916 }
917
918
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(chainlinks.Count()>0)
919 {
920 for(int32_t j=0; j<chainlinks.Count(); j++)
921 {
922 chainlinks.spr(j)->x+=dx;
923 }
924 }
925
926 1211 x=new_x;
927
928 // A kludge
929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1211 if(!diagonalMovement && dir<=down)
930 is_on_conveyor=true;
931 1211 }
932
933 1081 void HeroClass::setYfix(zfix new_y)
934 {
935 1081 zfix dy=new_y-y;
936 1081 justmoved = 2;
937
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHookshot)>-1)
938 {
939 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
940 hs_starty+=(int32_t)dy;
941 }
942
943
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHSHandle)>-1)
944 {
945 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
946 }
947
948
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(chainlinks.Count()>0)
949 {
950 for(int32_t j=0; j<chainlinks.Count(); j++)
951 {
952 chainlinks.spr(j)->y+=dy;
953 }
954 }
955
956 1081 y=new_y;
957
958 // A kludge
959
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1081 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1081 if(!diagonalMovement && dir>=left)
960 is_on_conveyor=true;
961 1081 }
962
963 2767 void HeroClass::setZfix(zfix new_z)
964 {
965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(isSideViewHero())
966 return;
967
968
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2754 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7 times.
2767 if(z==0 && new_z > 0)
969 {
970
1/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 switch(action)
971 {
972 case swimming:
973 {
974 diveclk=0;
975 action=walking; FFCore.setHeroAction(walking);
976 break;
977 }
978
979 case waterhold1:
980 {
981 action=landhold1; FFCore.setHeroAction(landhold1);
982 break;
983 }
984
985 case waterhold2:
986 {
987 action=landhold2; FFCore.setHeroAction(landhold2);
988 break;
989 }
990
991 default:
992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(charging) //!DIMITODO: Let Hero jump while charging sword
993 {
994 reset_swordcharge();
995 attackclk=0;
996 }
997
998 7 break;
999 }
1000 7 }
1001
1002
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 6 times.
2767 z=(new_z>0 ? new_z : zfix(0));
1003 2767 }
1004
1005 void HeroClass::setFakeZfix(zfix new_z)
1006 {
1007 if(isSideViewHero())
1008 return;
1009
1010 if(fakez==0 && new_z > 0)
1011 {
1012 switch(action)
1013 {
1014 case swimming:
1015 {
1016 diveclk=0;
1017 action=walking; FFCore.setHeroAction(walking);
1018 break;
1019 }
1020
1021 case waterhold1:
1022 {
1023 action=landhold1; FFCore.setHeroAction(landhold1);
1024 break;
1025 }
1026
1027 case waterhold2:
1028 {
1029 action=landhold2; FFCore.setHeroAction(landhold2);
1030 break;
1031 }
1032
1033 default:
1034 if(charging) //!DIMITODO: Let Hero jump while charging sword
1035 {
1036 reset_swordcharge();
1037 attackclk=0;
1038 }
1039
1040 break;
1041 }
1042 }
1043
1044 fakez=(new_z>0 ? new_z : zfix(0));
1045 }
1046
1047 64440 void HeroClass::setFall(zfix new_fall)
1048 {
1049 64440 fall=new_fall;
1050 64440 justmoved = 2;
1051 64440 jumping=-1;
1052 64440 }
1053 void HeroClass::setFakeFall(zfix new_fall)
1054 {
1055 fakefall=new_fall;
1056 jumping=-1;
1057 }
1058 void HeroClass::setClimbCoverX(int32_t new_x)
1059 {
1060 climb_cover_x=new_x;
1061 }
1062 void HeroClass::setClimbCoverY(int32_t new_y)
1063 {
1064 climb_cover_y=new_y;
1065 }
1066 40633 int32_t HeroClass::getLStep()
1067 {
1068 40633 return lstep;
1069 }
1070 2872 int32_t HeroClass::getCharging()
1071 {
1072 2872 return charging;
1073 }
1074 47610 bool HeroClass::isCharged()
1075 {
1076 47610 return spins>0;
1077 }
1078 int32_t HeroClass::getAttackClk()
1079 {
1080 return attackclk;
1081 }
1082 void HeroClass::setAttackClk(int32_t new_clk)
1083 {
1084 attackclk=new_clk;
1085 }
1086 void HeroClass::setCharging(int32_t new_charging)
1087 {
1088 charging=new_charging;
1089 }
1090 1628100702 int32_t HeroClass::getSwordClk()
1091 {
1092 1628100702 return swordclk;
1093 }
1094 1604902136 int32_t HeroClass::getItemClk()
1095 {
1096 1604902136 return itemclk;
1097 }
1098 5 void HeroClass::setSwordClk(int32_t newclk)
1099 {
1100 5 swordclk=newclk;
1101 5 verifyAWpn();
1102 5 }
1103 5 void HeroClass::setItemClk(int32_t newclk)
1104 {
1105 5 itemclk=newclk;
1106 5 }
1107 283047 zfix HeroClass::getModifiedX()
1108 {
1109 283047 zfix tempx=x;
1110
1111
4/4
✓ Branch 0 taken 58115 times.
✓ Branch 1 taken 224932 times.
✓ Branch 2 taken 36016 times.
✓ Branch 3 taken 22099 times.
283047 if(screenscrolling&&(dir==left))
1112 {
1113 22099 tempx=tempx+256;
1114 22099 }
1115
1116 283047 return tempx;
1117 }
1118
1119 283047 zfix HeroClass::getModifiedY()
1120 {
1121 283047 zfix tempy=y;
1122
1123
4/4
✓ Branch 0 taken 58115 times.
✓ Branch 1 taken 224932 times.
✓ Branch 2 taken 13967 times.
✓ Branch 3 taken 44148 times.
283047 if(screenscrolling&&(dir==up))
1124 {
1125 13967 tempy=tempy+176;
1126 13967 }
1127
1128 283047 return tempy;
1129 }
1130
1131 6476 int32_t HeroClass::getDir()
1132 {
1133 6476 return dir;
1134 }
1135 16584 void HeroClass::setDir(int32_t newdir)
1136 {
1137 16584 dir=newdir;
1138 16584 reset_hookshot();
1139 16584 }
1140 int32_t HeroClass::getHitDir()
1141 {
1142 return hitdir;
1143 }
1144 void HeroClass::setHitDir(int32_t newdir)
1145 {
1146 hitdir = newdir;
1147 }
1148 int32_t HeroClass::getClk()
1149 {
1150 return clk;
1151 }
1152 int32_t HeroClass::getPushing()
1153 {
1154 return pushing;
1155 }
1156 4941 void HeroClass::Catch()
1157 {
1158
5/6
✓ Branch 0 taken 4941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 1245 times.
✓ Branch 4 taken 1997 times.
✓ Branch 5 taken 1699 times.
4941 if(!inwallm && (action==none || action==walking))
1159 {
1160 3242 SetAttack();
1161 3242 attackclk=0;
1162 3242 attack=wCatching;
1163 3242 }
1164 4941 }
1165
1166 2984320 bool HeroClass::getClock()
1167 {
1168 2984320 return superman;
1169 }
1170 488 void HeroClass::setClock(bool state)
1171 {
1172 488 superman=state;
1173 488 }
1174 24213553 int32_t HeroClass::getAction() // Used by ZScript
1175 {
1176
2/2
✓ Branch 0 taken 7632 times.
✓ Branch 1 taken 24205921 times.
24213553 if(spins > 0)
1177 7632 return isspinning;
1178
2/2
✓ Branch 0 taken 17289 times.
✓ Branch 1 taken 24188632 times.
24205921 else if(charging > 0)
1179 17289 return ischarging;
1180
2/2
✓ Branch 0 taken 24171700 times.
✓ Branch 1 taken 16932 times.
24188632 else if(diveclk > 0)
1181 16932 return isdiving;
1182 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1183
1184 24171700 return action;
1185 24213553 }
1186
1187 18235485 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1188 {
1189
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 18234637 times.
18235485 if(spins > 0)
1190 848 return isspinning;
1191
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 18232716 times.
18234637 else if(charging > 0)
1192 1921 return ischarging;
1193
2/2
✓ Branch 0 taken 18215950 times.
✓ Branch 1 taken 16766 times.
18232716 else if(diveclk > 0)
1194 16766 return isdiving;
1195 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1196
1197 18215950 return -1;
1198 18235485 }
1199
1200 388 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1201 {
1202
4/8
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 388 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 388 times.
776 if(new_action==dying || new_action==won || new_action==scrolling ||
1203
3/6
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 388 times.
✗ Branch 5 not taken.
388 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1204 388 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1205 return; // Can't use these actions.
1206
1207
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
388 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1208 return;
1209
1210
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(new_action==rafting)
1211 {
1212 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1213 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1214 return;
1215 }
1216
1217
1218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if(magicitem>-1 && itemsbuf[magicitem].family==itype_faroreswind)
1219 {
1220 // Using Farore's Wind
1221 if(magiccastclk<96)
1222 {
1223 // Not cast yet; cancel it
1224 magicitem=-1;
1225 magiccastclk=0;
1226 }
1227 else
1228 // Already activated; don't do anything
1229 return;
1230 }
1231
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 if(action==inwind) // Remove from whirlwind
1233 {
1234 xofs=0;
1235 whirlwind=0;
1236 lstep=0;
1237 if ( dontdraw < 2 ) { dontdraw=0; }
1238 }
1239
2/4
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 388 times.
388 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1240 {
1241 sprite* wind=0;
1242 bool foundWind=false;
1243 for(int32_t i=0; i<Ewpns.Count(); i++)
1244 {
1245 wind=Ewpns.spr(i);
1246 if(wind->id==ewWind && wind->misc==999)
1247 {
1248 foundWind=true;
1249 break;
1250 }
1251 }
1252
1253 if(foundWind)
1254 {
1255 xofs=0;
1256 if ( dontdraw < 2 ) { dontdraw=false; }
1257 wind->misc=-1;
1258 x=wind->x;
1259 y=wind->y;
1260 }
1261 }
1262
1263 //Unless compat rule is on, reset hopping clocks when writing action!
1264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1265 {
1266 hopclk = 0;
1267 hopdir = -1;
1268 }
1269
1270
3/4
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 264 times.
388 if(new_action != attacking && new_action != sideswimattacking)
1271 {
1272 264 attackclk=0;
1273
1274
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(attack==wHookshot)
1275 reset_hookshot();
1276 264 }
1277
2/4
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 388 times.
388 if(new_action != isspinning && new_action != sideswimisspinning)
1278 {
1279 388 charging = 0;
1280 388 spins = 0;
1281 388 }
1282
1283
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if(action == falling && new_action != falling)
1284 {
1285 fallclk = 0; //Stop falling;
1286 }
1287
1288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if (action == rafting && new_action != rafting)
1289 {
1290 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1291 raftwarpy = y;
1292 }
1293
1294
2/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 264 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
388 switch(new_action)
1295 {
1296 case isspinning:
1297 case sideswimisspinning:
1298 if(attack==wSword)
1299 {
1300 attackclk = SWORDCHARGEFRAME+1;
1301 charging = 0;
1302
1303 if(spins==0)
1304 spins = 5;
1305 }
1306 return;
1307
1308 case isdiving:
1309 if(action==swimming && diveclk==0)
1310 {
1311 int32_t flippers_id = current_item_id(itype_flippers);
1312 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1313 }
1314 return;
1315
1316 case drowning:
1317 case sidedrowning:
1318 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1319 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1320 if(!drownclk)
1321 Drown();
1322
1323 break;
1324
1325 case lavadrowning:
1326 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1327 if(!drownclk)
1328 Drown(1);
1329
1330 break;
1331
1332 case falling:
1333 if(!fallclk)
1334 {
1335 //If there is a pit under Hero, use it's combo.
1336 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1337 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1338 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1339 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1340 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1341 //Else, use a null value; triggers default pit values
1342 else fallCombo = 0;
1343 fallclk = PITFALL_FALL_FRAMES;
1344 }
1345 break;
1346
1347 case gothit:
1348 case swimhit:
1349 case sideswimhit:
1350 if(!hclk)
1351 hclk=48;
1352
1353 break;
1354
1355 case landhold1:
1356 case landhold2:
1357 case waterhold1:
1358 case waterhold2:
1359 case sidewaterhold1:
1360 case sidewaterhold2:
1361 if(!holdclk)
1362 holdclk=130;
1363
1364 attack=none;
1365 break;
1366
1367 case attacking:
1368 case sideswimattacking:
1369 124 attack=none;
1370 124 break;
1371
1372 default:
1373 264 break;
1374 }
1375
1376 388 action=new_action; FFCore.setHeroAction(new_action);
1377 388 }
1378
1379 void HeroClass::setHeldItem(int32_t newitem)
1380 {
1381 holditem=newitem;
1382 }
1383 17 int32_t HeroClass::getHeldItem()
1384 {
1385 17 return holditem;
1386 }
1387 3439360 bool HeroClass::isDiving()
1388 {
1389 3439360 int32_t flippers_id = current_item_id(itype_flippers);
1390
2/2
✓ Branch 0 taken 2766806 times.
✓ Branch 1 taken 672554 times.
3439360 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1391 }
1392 7828630 bool HeroClass::isSwimming()
1393 {
1394
4/6
✓ Branch 0 taken 7774762 times.
✓ Branch 1 taken 53868 times.
✓ Branch 2 taken 7774762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7774762 times.
✗ Branch 5 not taken.
15603392 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1395
4/4
✓ Branch 0 taken 7773852 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 7773462 times.
7774762 (action==waterhold1)||(action==waterhold2)||
1396 7773462 (hopclk==0xFF));
1397 }
1398
1399 577 void HeroClass::setDontDraw(byte new_dontdraw)
1400 {
1401 577 dontdraw=new_dontdraw;
1402 577 }
1403
1404 336214 byte HeroClass::getDontDraw()
1405 {
1406 336214 return dontdraw;
1407 }
1408
1409 void HeroClass::setHClk(int32_t newhclk)
1410 {
1411 hclk=newhclk;
1412 }
1413
1414 87306 int32_t HeroClass::getHClk()
1415 {
1416 87306 return hclk;
1417 }
1418
1419 1324341 int32_t HeroClass::getSpecialCave()
1420 {
1421 1324341 return specialcave; // used only by maps.cpp
1422 }
1423
1424 203 void HeroClass::init()
1425 {
1426 203 usecounts.clear();
1427 203 scale = 0;
1428 203 rotation = 0;
1429 203 do_animation = 1;
1430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if(lift_wpn)
1431 {
1432 delete lift_wpn;
1433 lift_wpn = nullptr;
1434 }
1435 203 liftclk = 0;
1436 203 tliftclk = 0;
1437 203 liftheight = 0;
1438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1439 203 hookshot_used=false;
1440 203 justmoved = 0;
1441 203 hookshot_frozen=false;
1442 203 onpassivedmg=false;
1443 203 dir = up;
1444 203 damageovertimeclk = 0;
1445 203 newconveyorclk = 0;
1446 203 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1447
2/2
✓ Branch 0 taken 1421 times.
✓ Branch 1 taken 203 times.
1624 for(auto q = 0; q < 7; ++q)
1448 1421 hooked_undercombos[q] = -1;
1449 203 shiftdir = -1;
1450 203 sideswimdir = right;
1451 203 holddir = -1;
1452 203 landswim = 0;
1453 203 sdir = up;
1454 203 ilswim=true;
1455 203 walkable=false;
1456 203 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1457 203 warp_sound = 0;
1458 203 subscr_speed = zinit.subscrSpeed;
1459 203 steprate = zinit.heroStep;
1460 203 is_warping = false;
1461 203 can_mirror_portal = true;
1462 203 coyotetime = 0;
1463
1464 203 hammer_swim_up_offset = hammeroffsets[0];
1465 203 hammer_swim_down_offset = hammeroffsets[1];
1466 203 hammer_swim_left_offset = hammeroffsets[2];
1467 203 hammer_swim_right_offset = hammeroffsets[3];
1468
1469 203 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1470
1471
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 127 times.
203 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1472 {
1473 76 x=tmpscr->warpreturnx[0];
1474 76 y=tmpscr->warpreturny[0];
1475 76 }
1476 else
1477 {
1478 127 x=tmpscr->warparrivalx;
1479 127 y=tmpscr->warparrivaly;
1480 }
1481
1482 203 z=fakez=fall=fakefall=0;
1483 203 hzsz = 12; // So that flying peahats can still hit him.
1484
1485
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 151 times.
203 if(x==0) dir=right;
1486
1487
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 202 times.
203 if(x==240) dir=left;
1488
1489
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 149 times.
203 if(y==0) dir=down;
1490
1491
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 165 times.
203 if(y==160) dir=up;
1492
1493 203 lstep=0;
1494 203 skipstep=0;
1495 203 autostep=false;
1496 203 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1497 203 attack=wNone;
1498 203 attackid=-1;
1499 203 action=none; FFCore.setHeroAction(none); tempaction=none;
1500 203 xofs=0;
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1502 203 cs=6;
1503 203 pushing=fairyclk=0;
1504 203 id=0;
1505 203 inlikelike=0;
1506 203 superman=inwallm=false;
1507 203 scriptcoldet=1;
1508 203 blowcnt=whirlwind=specialcave=0;
1509 203 hopclk=diveclk=fallclk=0;
1510 203 fallCombo = 0;
1511 203 pit_pulldir = -1;
1512 203 hopdir=-1;
1513 203 conveyor_flags=0;
1514 203 drunkclk=0;
1515 203 lstunclock = 0;
1516 203 is_conveyor_stunned=0;
1517 203 drawstyle=3;
1518 203 ffwarp = false;
1519 203 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1520 203 stepnext=stepsecret=-1;
1521 203 ffpit = false;
1522 203 respawn_x=x;
1523 203 respawn_y=y;
1524 203 respawn_dmap=currdmap;
1525 203 respawn_scr=currscr;
1526 203 falling_oldy = y;
1527 203 magiccastclk=0;
1528 203 magicitem = nayruitem = -1;
1529 203 last_lens_id = 0; //Should be -1 (-Z)
1530 203 last_savepoint_id = 0;
1531 203 misc_internal_hero_flags = 0;
1532 203 last_cane_of_byrna_item_id = -1;
1533 203 on_sideview_ladder = false;
1534 203 switchblock_z = 0;
1535 203 switchblock_offset = false;
1536 203 extra_jump_count = 0;
1537 203 hoverflags = 0;
1538 203 lbunnyclock = 0;
1539
1540
2/2
✓ Branch 0 taken 6496 times.
✓ Branch 1 taken 203 times.
6699 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1541
1542 203 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1543 203 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1544
1545 203 shield_active = false;
1546 203 shield_forcedir = -1;
1547 203 active_shield_id = -1;
1548
1549 //2.6
1550 203 preventsubscreenfalling = false; //-Z
1551 203 walkspeed = 0; //not used, yet. -Z
1552
2/2
✓ Branch 0 taken 3248 times.
✓ Branch 1 taken 203 times.
3451 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1553
2/2
✓ Branch 0 taken 3248 times.
✓ Branch 1 taken 203 times.
3451 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1554
2/2
✓ Branch 0 taken 29638 times.
✓ Branch 1 taken 203 times.
29841 for ( int32_t q = 0; q < wMax; q++ )
1555 {
1556 29638 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1557 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1558 29638 }
1559 //Run script!
1560
4/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 15 times.
203 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1561 {
1562 14 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1563 14 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1564 14 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1565 14 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1566 //are properly set by the engine.
1567 14 }
1568 203 FFCore.nostepforward = 0;
1569 203 }
1570
1571 4192403 void HeroClass::draw_under(BITMAP* dest)
1572 {
1573 4192403 int32_t c_raft=current_item_id(itype_raft);
1574 4192403 int32_t c_ladder=current_item_id(itype_ladder);
1575
1576
3/4
✓ Branch 0 taken 26984 times.
✓ Branch 1 taken 4165419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26984 times.
4192403 if(action==rafting && c_raft >-1)
1577 {
1578
4/4
✓ Branch 0 taken 19335 times.
✓ Branch 1 taken 7649 times.
✓ Branch 2 taken 17507 times.
✓ Branch 3 taken 9477 times.
26984 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1579 {
1580 18954 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1581 9477 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1582 9477 }
1583 else
1584 {
1585 35014 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1586 17507 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1587 }
1588 26984 }
1589
1590
3/4
✓ Branch 0 taken 51582 times.
✓ Branch 1 taken 4140821 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51582 times.
4192403 if(ladderx+laddery && c_ladder >-1)
1591 {
1592
4/4
✓ Branch 0 taken 24599 times.
✓ Branch 1 taken 26983 times.
✓ Branch 2 taken 6232 times.
✓ Branch 3 taken 18367 times.
51582 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1593 {
1594 12464 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1595 6232 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1596 6232 }
1597 else
1598 {
1599 90700 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1600 45350 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1601 }
1602 51582 }
1603 4192403 }
1604
1605 3357 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1606 {
1607 3357 int32_t tempy=yofs;
1608 3357 yofs+=8;
1609 3357 shadowtile = wpnsbuf[spr_shadow].tile;
1610 3357 sprite::drawshadow(dest,translucent);
1611 3357 yofs=tempy;
1612 3357 }
1613
1614 // The Stone of Agony reacts to these flags.
1615 465328 bool HeroClass::agonyflag(int32_t flag)
1616 {
1617
2/2
✓ Branch 0 taken 465296 times.
✓ Branch 1 taken 32 times.
465328 switch(flag)
1618 {
1619 case mfWHISTLE:
1620 case mfBCANDLE:
1621 case mfARROW:
1622 case mfBOMB:
1623 case mfSBOMB:
1624 case mfBRANG:
1625 case mfMBRANG:
1626 case mfFBRANG:
1627 case mfSARROW:
1628 case mfGARROW:
1629 case mfRCANDLE:
1630 case mfWANDFIRE:
1631 case mfDINSFIRE:
1632 case mfWANDMAGIC:
1633 case mfREFMAGIC:
1634 case mfREFFIREBALL:
1635 case mfSWORD:
1636 case mfWSWORD:
1637 case mfMSWORD:
1638 case mfXSWORD:
1639 case mfSWORDBEAM:
1640 case mfWSWORDBEAM:
1641 case mfMSWORDBEAM:
1642 case mfXSWORDBEAM:
1643 case mfHOOKSHOT:
1644 case mfWAND:
1645 case mfHAMMER:
1646 case mfSTRIKE:
1647 32 return true;
1648 }
1649
1650 465296 return false;
1651 465328 }
1652
1653
1654 // Find the attack power of the current melee weapon.
1655 // The Whimsical Ring is applied on a target-by-target basis.
1656 329132 int32_t HeroClass::weaponattackpower(int32_t itid)
1657 {
1658
1/2
✓ Branch 0 taken 329132 times.
✗ Branch 1 not taken.
329132 if(itid < 0)
1659 {
1660 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1661 : attack==wWand ? itype_wand
1662 : attack==wHammer ? itype_hammer
1663 : itype_sword);
1664 }
1665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 329132 times.
329132 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1666
1667 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1668
5/6
✓ Branch 0 taken 328558 times.
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574 times.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 131 times.
329132 power *= (spins>0 ? itemsbuf[current_item_id(attack==wHammer ? itype_quakescroll : (spins>5 || current_item_id(itype_spinscroll) < 0) ? itype_spinscroll2 : itype_spinscroll)].power : 1);
1669 329132 return power;
1670 }
1671
1672 #define NET_CLK_TOTAL 24
1673 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1674 // Must only be called once per frame!
1675 void HeroClass::positionNet(weapon *w, int32_t itemid)
1676 {
1677 itemid = vbound(itemid, 0, MAXITEMS-1);
1678 int32_t t = w->o_tile,
1679 wx = 1, wy = 1;
1680
1681 //Invert positioning clock if right-handed animation
1682 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1683 if(clock >= NET_CLK_TOTAL)
1684 w->dead = 0;
1685 int32_t tiledir = dir;
1686 switch(dir)
1687 {
1688 case up:
1689 {
1690 if(clock < NET_DIR_INC) tiledir = l_up;
1691 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1692 break;
1693 }
1694 case down:
1695 {
1696 if(clock < NET_DIR_INC) tiledir = r_down;
1697 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1698 break;
1699 }
1700 case left:
1701 {
1702 if(clock < NET_DIR_INC) tiledir = l_down;
1703 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1704 break;
1705 }
1706 case right:
1707 {
1708 if(clock < NET_DIR_INC) tiledir = r_up;
1709 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1710 break;
1711 }
1712 }
1713 int32_t offs = 0;
1714 if(tiledir > right)
1715 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1716 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1717 //One of 8 positions
1718 switch(tiledir)
1719 {
1720 case up:
1721 {
1722 wx = 6*offs;
1723 wy = -14;
1724 break;
1725 }
1726 case r_up:
1727 {
1728 wx = (offs ? 10 : 14);
1729 wy = (offs ? -12 : -10);
1730 break;
1731 }
1732 case right:
1733 {
1734 wx = 14;
1735 wy = 6*offs;
1736 break;
1737 }
1738 case r_down:
1739 {
1740 wx = (offs ? 14 : 10);
1741 wy = (offs ? 10 : 12);
1742 break;
1743 }
1744 case down:
1745 {
1746 wx = -6*offs;
1747 wy = 14;
1748 break;
1749 }
1750 case l_down:
1751 {
1752 wx = (offs ? -10 : -14);
1753 wy = (offs ? 12 : 10);
1754 break;
1755 }
1756 case left:
1757 {
1758 wx = -14;
1759 wy = -6*offs;
1760 break;
1761 }
1762 case l_up:
1763 {
1764 wx = (offs ? -14 : -10);
1765 wy = (offs ? -10 : -12);
1766 break;
1767 }
1768 }
1769
1770 w->x = x+wx;
1771 w->y = y+wy-(54-(yofs))-fakez;
1772 w->z = (z+zofs);
1773 w->fakez = fakez;
1774 w->tile = t+tiledir;
1775 w->power = 0;
1776 w->dir = dir;
1777 w->doAutoRotate(true);
1778 }
1779 301801 void HeroClass::positionSword(weapon *w, int32_t itemid)
1780 {
1781 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1782 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1783 301801 itemid=vbound(itemid, 0, MAXITEMS-1);
1784 // Place a sword weapon at the right spot.
1785 301801 int32_t wy=1;
1786 301801 int32_t wx=1;
1787 301801 int32_t f=0,t,cs2;
1788
1789 301801 t = w->o_tile;
1790 301801 cs2 = w->o_cset;
1791 301801 slashxofs=0;
1792 301801 slashyofs=0;
1793
1794
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 64217 times.
✓ Branch 2 taken 65909 times.
✓ Branch 3 taken 85885 times.
✓ Branch 4 taken 85790 times.
301801 switch(dir)
1795 {
1796 case up:
1797 64217 wx=-1;
1798 64217 wy=-12;
1799
1800
7/8
✓ Branch 0 taken 6624 times.
✓ Branch 1 taken 57593 times.
✓ Branch 2 taken 5581 times.
✓ Branch 3 taken 1043 times.
✓ Branch 4 taken 5171 times.
✓ Branch 5 taken 410 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5171 times.
64217 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1801 {
1802
2/2
✓ Branch 0 taken 3380 times.
✓ Branch 1 taken 1791 times.
5171 if(attackclk>10) //extended stab
1803 {
1804 1791 slashyofs-=3;
1805 1791 wy-=2;
1806 1791 }
1807
1808
2/2
✓ Branch 0 taken 4724 times.
✓ Branch 1 taken 447 times.
5171 if(attackclk>=14) //retracting stab
1809 {
1810 447 slashyofs+=3;
1811 447 wy+=2;
1812 447 }
1813 5171 }
1814 else
1815 {
1816
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 58760 times.
59046 if(attackclk==SWORDCHARGEFRAME)
1817 {
1818 286 wy+=4;
1819 286 }
1820
2/2
✓ Branch 0 taken 5677 times.
✓ Branch 1 taken 53083 times.
58760 else if(attackclk==13)
1821 {
1822 5677 wy+=4;
1823 5677 }
1824
2/2
✓ Branch 0 taken 47500 times.
✓ Branch 1 taken 5583 times.
53083 else if(attackclk==14)
1825 {
1826 5583 wy+=8;
1827 5583 }
1828 }
1829
1830 64217 break;
1831
1832 case down:
1833 65909 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1834 65909 wy=11;
1835
1836
7/8
✓ Branch 0 taken 9210 times.
✓ Branch 1 taken 56699 times.
✓ Branch 2 taken 8463 times.
✓ Branch 3 taken 747 times.
✓ Branch 4 taken 8103 times.
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8103 times.
65909 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1837 {
1838
2/2
✓ Branch 0 taken 5263 times.
✓ Branch 1 taken 2840 times.
8103 if(attackclk>10) //extended stab
1839 {
1840 2840 slashyofs+=3;
1841 2840 wy+=2;
1842 2840 }
1843
1844
2/2
✓ Branch 0 taken 7405 times.
✓ Branch 1 taken 698 times.
8103 if(attackclk>=14) //retracting stab
1845 {
1846 698 slashyofs-=3;
1847 698 wy-=2;
1848 698 }
1849 8103 }
1850 else
1851 {
1852
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 57206 times.
57806 if(attackclk==SWORDCHARGEFRAME)
1853 {
1854 600 wy-=2;
1855 600 }
1856
2/2
✓ Branch 0 taken 5594 times.
✓ Branch 1 taken 51612 times.
57206 else if(attackclk==13)
1857 {
1858 5594 wy-=4;
1859 5594 }
1860
2/2
✓ Branch 0 taken 46043 times.
✓ Branch 1 taken 5569 times.
51612 else if(attackclk==14)
1861 {
1862 5569 wy-=8;
1863 5569 }
1864 }
1865
1866 65909 break;
1867
1868 case left:
1869 85885 f=1;
1870 85885 wx=-11;
1871 85885 ++t;
1872
1873
7/8
✓ Branch 0 taken 12725 times.
✓ Branch 1 taken 73160 times.
✓ Branch 2 taken 10407 times.
✓ Branch 3 taken 2318 times.
✓ Branch 4 taken 9555 times.
✓ Branch 5 taken 852 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9555 times.
85885 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1874 {
1875
2/2
✓ Branch 0 taken 6123 times.
✓ Branch 1 taken 3432 times.
9555 if(attackclk>10) //extended stab
1876 {
1877 3432 slashxofs-=4;
1878 3432 wx-=7;
1879 3432 }
1880
1881
2/2
✓ Branch 0 taken 8702 times.
✓ Branch 1 taken 853 times.
9555 if(attackclk>=14) //retracting stab
1882 {
1883 853 slashxofs+=3;
1884 853 wx+=7;
1885 853 }
1886 9555 }
1887 else
1888 {
1889
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 76127 times.
76330 if(attackclk==SWORDCHARGEFRAME)
1890 {
1891 203 wx+=2;
1892 203 }
1893
2/2
✓ Branch 0 taken 7488 times.
✓ Branch 1 taken 68639 times.
76127 else if(attackclk==13)
1894 {
1895 7488 wx+=4;
1896 7488 }
1897
2/2
✓ Branch 0 taken 61182 times.
✓ Branch 1 taken 7457 times.
68639 else if(attackclk==14)
1898 {
1899 7457 wx+=8;
1900 7457 }
1901 }
1902
1903 85885 break;
1904
1905 case right:
1906 85790 wx=11;
1907 85790 ++t;
1908
1909
7/8
✓ Branch 0 taken 12834 times.
✓ Branch 1 taken 72956 times.
✓ Branch 2 taken 10987 times.
✓ Branch 3 taken 1847 times.
✓ Branch 4 taken 9153 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 9153 times.
✗ Branch 7 not taken.
85790 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1910 {
1911
2/2
✓ Branch 0 taken 5871 times.
✓ Branch 1 taken 3282 times.
9153 if(attackclk>10) //extended stab
1912 {
1913 3282 slashxofs+=4;
1914 3282 wx+=7;
1915 3282 }
1916
1917
2/2
✓ Branch 0 taken 8334 times.
✓ Branch 1 taken 819 times.
9153 if(attackclk>=14) //retracting stab
1918 {
1919 819 slashxofs-=3;
1920 819 wx-=7;
1921 819 }
1922 9153 }
1923 else
1924 {
1925
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 76042 times.
76637 if(attackclk==SWORDCHARGEFRAME)
1926 {
1927 595 wx-=2;
1928 595 }
1929
2/2
✓ Branch 0 taken 7446 times.
✓ Branch 1 taken 68596 times.
76042 else if(attackclk==13)
1930 {
1931 7446 wx-=4;
1932 7446 }
1933
2/2
✓ Branch 0 taken 61172 times.
✓ Branch 1 taken 7424 times.
68596 else if(attackclk==14)
1934 {
1935 7424 wx-=8;
1936 7424 }
1937 }
1938
1939 85790 break;
1940 }
1941
1942
6/6
✓ Branch 0 taken 41393 times.
✓ Branch 1 taken 260408 times.
✓ Branch 2 taken 31982 times.
✓ Branch 3 taken 9411 times.
✓ Branch 4 taken 11345 times.
✓ Branch 5 taken 20637 times.
301801 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1943 {
1944 20637 int32_t wpn2=itemsbuf[itemid].wpn2;
1945 20637 wpn2=vbound(wpn2, 0, MAXWPNS);
1946
1947 //slashing tiles
1948
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3380 times.
✓ Branch 2 taken 5263 times.
✓ Branch 3 taken 6123 times.
✓ Branch 4 taken 5871 times.
20637 switch(dir)
1949 {
1950 case up:
1951 3380 wx=15;
1952 3380 wy=-3;
1953 3380 ++t;
1954 3380 f=0; //starts pointing right
1955
1956
2/2
✓ Branch 0 taken 1518 times.
✓ Branch 1 taken 1862 times.
3380 if(attackclk>=7)
1957 {
1958 1862 wy-=9;
1959 1862 wx-=3;
1960 1862 t = wpnsbuf[wpn2].tile;
1961 1862 cs2 = wpnsbuf[wpn2].csets&15;
1962 1862 f=0;
1963 1862 }
1964
1965 3380 break;
1966
1967 case down:
1968 5263 wx=-13;
1969 5263 wy=-1;
1970 5263 ++t;
1971 5263 f=1; //starts pointing left
1972
1973
2/2
✓ Branch 0 taken 2290 times.
✓ Branch 1 taken 2973 times.
5263 if(attackclk>=7)
1974 {
1975 2973 wy+=15;
1976 2973 wx+=2;
1977 2973 t = wpnsbuf[wpn2].tile;
1978 2973 cs2 = wpnsbuf[wpn2].csets&15;
1979 2973 ++t;
1980 2973 f=0;
1981 2973 }
1982
1983 5263 break;
1984
1985 case left:
1986 6123 wx=3;
1987 6123 wy=-15;
1988 6123 --t;
1989 6123 f=0; //starts pointing up
1990
1991
2/2
✓ Branch 0 taken 2652 times.
✓ Branch 1 taken 3471 times.
6123 if(attackclk>=7)
1992 {
1993 3471 wx-=15;
1994 3471 wy+=3;
1995 3471 slashxofs-=1;
1996 3471 t = wpnsbuf[wpn2].tile;
1997 3471 cs2 = wpnsbuf[wpn2].csets&15;
1998 3471 t+=2;
1999 3471 f=0;
2000 3471 }
2001
2002 6123 break;
2003
2004 case right:
2005 5871 --t;
2006
2007
2/4
✓ Branch 0 taken 5871 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5871 times.
5871 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2008 {
2009 wx=1;
2010 wy=13;
2011 f=2;
2012 }
2013 else
2014 {
2015 5871 wx=3;
2016 5871 wy=-15;
2017 5871 f=0;
2018 }
2019
2020
2/2
✓ Branch 0 taken 2553 times.
✓ Branch 1 taken 3318 times.
5871 if(attackclk>=7)
2021 {
2022 3318 wx+=15;
2023 3318 slashxofs+=1;
2024 3318 t = wpnsbuf[wpn2].tile;
2025 3318 cs2 = wpnsbuf[wpn2].csets&15;
2026
2027
2/4
✓ Branch 0 taken 3318 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3318 times.
3318 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2028 {
2029 wx-=1;
2030 wy-=2;
2031 }
2032 else
2033 {
2034 3318 t+=3;
2035 3318 f=0;
2036 3318 wy+=3;
2037 }
2038 3318 }
2039
2040 5871 break;
2041 }
2042 20637 }
2043
2044 301801 int32_t itemid2 = current_item_id(itype_chargering);
2045
2046
4/4
✓ Branch 0 taken 21482 times.
✓ Branch 1 taken 280319 times.
✓ Branch 2 taken 301269 times.
✓ Branch 3 taken 532 times.
301801 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2047 {
2048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2049 532 }
2050
2051 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2052 {
2053 wy+=2;
2054 }*/
2055 301801 w->x = x+wx;
2056 301801 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2057 301801 w->z = (z+zofs);
2058 301801 w->tile = t;
2059 301801 w->flip = f;
2060 301801 w->power = weaponattackpower(itemid);
2061 301801 w->dir = dir;
2062 301801 w->doAutoRotate(true);
2063 301801 }
2064
2065 4213615 void HeroClass::draw(BITMAP* dest)
2066 {
2067 /*{
2068 char buf[36];
2069 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2070 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2071 }*/
2072 int32_t oxofs, oyofs;
2073 4213615 bool shieldModify = false;
2074
2/2
✓ Branch 0 taken 4204214 times.
✓ Branch 1 taken 9401 times.
4213615 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2075
2076
2/2
✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 4212235 times.
4213615 if(action==dying)
2077 {
2078
2/2
✓ Branch 0 taken 1058 times.
✓ Branch 1 taken 322 times.
1380 if(!invisible)
2079 {
2080
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2081 322 sprite::draw(dest);
2082 322 }
2083 1380 return;
2084 }
2085
2086 4212235 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2087
2088 4212235 oxofs=xofs;
2089 4212235 oyofs=yofs;
2090
2091
2/2
✓ Branch 0 taken 25950 times.
✓ Branch 1 taken 4186285 times.
4212235 if(!invisible)
2092
6/6
✓ Branch 0 taken 3591222 times.
✓ Branch 1 taken 595063 times.
✓ Branch 2 taken 2584484 times.
✓ Branch 3 taken 1006738 times.
✓ Branch 4 taken 129761 times.
✓ Branch 5 taken 2454723 times.
4186285 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2093
2094 // Stone of Agony
2095 4212235 bool agony=false;
2096 4212235 int32_t agonyid = current_item_id(itype_agony);
2097
2098
2/2
✓ Branch 0 taken 25950 times.
✓ Branch 1 taken 4186285 times.
4212235 if(invisible)
2099 25950 goto attack;
2100
2101
2/2
✓ Branch 0 taken 3953613 times.
✓ Branch 1 taken 232672 times.
4186285 if(agonyid>-1)
2102 {
2103 232672 int32_t power=itemsbuf[agonyid].power;
2104 232672 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2105 232672 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2106 232672 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2107 232672 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2108
2109
2/2
✓ Branch 0 taken 232672 times.
✓ Branch 1 taken 232672 times.
465344 for(int32_t x=left; x<right; x+=16)
2110 {
2111
2/2
✓ Branch 0 taken 232640 times.
✓ Branch 1 taken 232672 times.
465312 for(int32_t y=top; y<bottom; y+=16)
2112 {
2113
4/4
✓ Branch 0 taken 232656 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 232640 times.
232672 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2114 {
2115 32 agony=true;
2116 32 x=right; // Break out of outer loop
2117 32 break;
2118 }
2119 232640 }
2120 232672 }
2121 232672 }
2122
2123 4186285 cs = 6;
2124
1/2
✓ Branch 0 taken 4186285 times.
✗ Branch 1 not taken.
4186285 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2125
2/2
✓ Branch 0 taken 1301062 times.
✓ Branch 1 taken 2885223 times.
7071508 if(!get_bit(quest_rules,qr_HEROFLICKER))
2126 {
2127
3/4
✓ Branch 0 taken 55980 times.
✓ Branch 1 taken 2829243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55980 times.
2885223 if(superman && getCanFlicker())
2128 {
2129 55980 cs += (((~frame)>>1)&3);
2130 55980 }
2131
4/6
✓ Branch 0 taken 136966 times.
✓ Branch 1 taken 2692277 times.
✓ Branch 2 taken 136966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 136966 times.
2829243 else if(hclk&&(NayrusLoveShieldClk<=0) && getCanFlicker())
2132 {
2133 136966 cs += ((hclk>>1)&3);
2134 136966 }
2135 2885223 }
2136
2137 attack:
2138
2139
5/6
✓ Branch 0 taken 3684672 times.
✓ Branch 1 taken 527563 times.
✓ Branch 2 taken 3681359 times.
✓ Branch 3 taken 3313 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3681359 times.
4212235 if(attackclk || (action==attacking||action==sideswimattacking))
2140 {
2141 /* Spaghetti code constants!
2142 * - Hero.attack contains a weapon type...
2143 * - which must be converted to an itype...
2144 * - which must be converted to an item ID...
2145 * - which is used to acquire a wpn ID! Aack!
2146 */
2147
7/8
✓ Branch 0 taken 10523 times.
✓ Branch 1 taken 520353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 520353 times.
✓ Branch 4 taken 16780 times.
✓ Branch 5 taken 503573 times.
✓ Branch 6 taken 2599 times.
✓ Branch 7 taken 500974 times.
530876 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2148
4/4
✓ Branch 0 taken 29427 times.
✓ Branch 1 taken 501449 times.
✓ Branch 2 taken 907 times.
✓ Branch 3 taken 28520 times.
530876 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2149 530876 itemid=vbound(itemid, 0, MAXITEMS-1);
2150 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2151
7/8
✓ Branch 0 taken 168238 times.
✓ Branch 1 taken 362638 times.
✓ Branch 2 taken 168238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118429 times.
✓ Branch 5 taken 49809 times.
✓ Branch 6 taken 13446 times.
✓ Branch 7 taken 104983 times.
530876 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2152 {
2153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376084 times.
376084 if(attack == wBugNet)
2154 {
2155 weapon *w=NULL;
2156 bool found = false;
2157 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2158 {
2159 w = (weapon*)Lwpns.spr(q);
2160 if(w->id == wBugNet)
2161 {
2162 found = true;
2163 break;
2164 }
2165 }
2166 if(!found)
2167 {
2168 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2169
2170 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2171 }
2172 positionNet(w, itemid);
2173 }
2174
8/8
✓ Branch 0 taken 76210 times.
✓ Branch 1 taken 299874 times.
✓ Branch 2 taken 64226 times.
✓ Branch 3 taken 11984 times.
✓ Branch 4 taken 56999 times.
✓ Branch 5 taken 7227 times.
✓ Branch 6 taken 64226 times.
✓ Branch 7 taken 311858 times.
376084 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2175 {
2176 // Create a sword weapon at the right spot.
2177 311858 weapon *w=NULL;
2178 311858 bool found = false;
2179
2180 // Look for pre-existing sword
2181
2/2
✓ Branch 0 taken 30042 times.
✓ Branch 1 taken 366858 times.
396900 for(int32_t i=0; i<Lwpns.Count(); i++)
2182 {
2183 366858 w = (weapon*)Lwpns.spr(i);
2184
2185
2/2
✓ Branch 0 taken 85042 times.
✓ Branch 1 taken 281816 times.
366858 if(w->id == (attack==wSword ? wSword : wWand))
2186 {
2187 281816 found = true;
2188 281816 break;
2189 }
2190 85042 }
2191
2192
2/2
✓ Branch 0 taken 281816 times.
✓ Branch 1 taken 30042 times.
311858 if(!found) // Create one if sword nonexistant
2193 {
2194
5/10
✓ Branch 0 taken 30042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30042 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30042 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30042 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 30042 times.
✗ Branch 9 not taken.
30042 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2195 30042 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2196
2197 30042 positionSword(w,itemid);
2198
2199 // Stone of Agony
2200
1/2
✓ Branch 0 taken 30042 times.
✗ Branch 1 not taken.
30042 if(agony)
2201 {
2202 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2203 }
2204 30042 }
2205
2206 // These are set by positionSword(), above or in checkstab()
2207 311858 yofs += slashyofs;
2208 311858 xofs += slashxofs;
2209 311858 slashyofs = slashxofs = 0;
2210 311858 }
2211 376084 }
2212
2213 530876 if(attackclk<7
2214
4/4
✓ Branch 0 taken 283927 times.
✓ Branch 1 taken 246949 times.
✓ Branch 2 taken 228197 times.
✓ Branch 3 taken 55730 times.
530876 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2215
4/6
✓ Branch 0 taken 51413 times.
✓ Branch 1 taken 176784 times.
✓ Branch 2 taken 51413 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51413 times.
228197 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2216
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 49600 times.
51413 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2217
4/4
✓ Branch 0 taken 97362 times.
✓ Branch 1 taken 7968 times.
✓ Branch 2 taken 91783 times.
✓ Branch 3 taken 5579 times.
107143 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2218
4/4
✓ Branch 0 taken 9900 times.
✓ Branch 1 taken 95430 times.
✓ Branch 2 taken 2077 times.
✓ Branch 3 taken 93353 times.
105330 || (attack==wHammer && attackclk<=30)
2219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93353 times.
95430 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2220 {
2221
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 437501 times.
437523 if(!invisible)
2222 {
2223 437501 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2224
2/4
✓ Branch 0 taken 437501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437501 times.
✗ Branch 3 not taken.
437501 if (FIXED_Z3_ANIMATION)
2225 {
2226 if (attackclk >= 2) tile += (extend==2?2:1);
2227 if (attackclk >= 13) tile += (extend==2?2:1);
2228 }
2229
2230
14/18
✓ Branch 0 taken 57929 times.
✓ Branch 1 taken 379572 times.
✓ Branch 2 taken 12515 times.
✓ Branch 3 taken 45414 times.
✓ Branch 4 taken 5295 times.
✓ Branch 5 taken 7220 times.
✓ Branch 6 taken 4572 times.
✓ Branch 7 taken 723 times.
✓ Branch 8 taken 40992 times.
✓ Branch 9 taken 16937 times.
✓ Branch 10 taken 22927 times.
✓ Branch 11 taken 18065 times.
✓ Branch 12 taken 22927 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 22927 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
437501 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2231 {
2232 18065 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2233
2/4
✓ Branch 0 taken 18065 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18065 times.
✗ Branch 3 not taken.
18065 if (FIXED_Z3_ANIMATION)
2234 {
2235 if (attackclk >= 7) tile += (extend==2?2:1);
2236 if (attackclk >= 11) tile += (extend==2?2:1);
2237 if (attackclk >= 14) tile += (extend==2?2:1);
2238 }
2239 18065 }
2240
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 437501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
437501 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2241 {
2242 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2243 {
2244 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2245 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2246 }
2247 else
2248 {
2249 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2250 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2251 }
2252 }
2253
2254
4/4
✓ Branch 0 taken 2599 times.
✓ Branch 1 taken 434902 times.
✓ Branch 2 taken 1548 times.
✓ Branch 3 taken 1051 times.
437501 if((attack==wHammer) && (attackclk<13))
2255 {
2256 1051 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2257
2/4
✓ Branch 0 taken 1051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1051 times.
✗ Branch 3 not taken.
1051 if (FIXED_Z3_ANIMATION)
2258 {
2259 if (attackclk >= 14) tile += (extend==2?2:1);
2260 if (attackclk >= 16) tile += (extend==2?2:1);
2261 }
2262 1051 }
2263
2264
2/2
✓ Branch 0 taken 396035 times.
✓ Branch 1 taken 41466 times.
437501 if(useltm)
2265 {
2266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41466 times.
41466 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2267 41466 }
2268
2269 // Stone of Agony
2270
1/2
✓ Branch 0 taken 437501 times.
✗ Branch 1 not taken.
437501 if(agony)
2271 {
2272 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2273 }
2274
2275 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2276
2277 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2278
6/6
✓ Branch 0 taken 137706 times.
✓ Branch 1 taken 299795 times.
✓ Branch 2 taken 134100 times.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 11476 times.
✓ Branch 5 taken 126230 times.
437501 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2279 {
2280 426025 masked_draw(dest);
2281 426025 }
2282
2283 //Prevent flickering -Z
2284
1/2
✓ Branch 0 taken 437501 times.
✗ Branch 1 not taken.
437501 if (!getCanFlicker()) masked_draw(dest);
2285 437501 }
2286
2287
2/2
✓ Branch 0 taken 434924 times.
✓ Branch 1 taken 2599 times.
437523 if(attack!=wHammer)
2288 {
2289 434924 xofs=oxofs;
2290 434924 yofs=oyofs;
2291 434924 return;
2292 }
2293 2599 }
2294
2295
2/2
✓ Branch 0 taken 2599 times.
✓ Branch 1 taken 93353 times.
95952 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2296 {
2297 2599 int32_t wy=1;
2298 2599 int32_t wx=1;
2299 2599 int32_t f=0,t,cs2;
2300 2599 weapon *w=NULL;
2301 2599 bool found = false;
2302
2303
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 2512 times.
2599 for(int32_t i=0; i<Lwpns.Count(); i++)
2304 {
2305 2512 w = (weapon*)Lwpns.spr(i);
2306
2307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2512 times.
2512 if(w->id == wHammer)
2308 {
2309 2512 found = true;
2310 2512 break;
2311 }
2312 }
2313
2314
2/2
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 87 times.
2599 if(!found)
2315 {
2316
5/10
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 87 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 87 times.
✗ Branch 9 not taken.
87 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2317 87 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2318 87 found = true;
2319 87 }
2320
2321 2599 t = w->o_tile;
2322 2599 cs2 = w->o_cset;
2323
2324
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 788 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 1178 times.
2599 switch(dir)
2325 {
2326 case up:
2327 788 wx=-1;
2328 788 wy=-15;
2329
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if (IsSideSwim())wy+=hammer_swim_up_offset;
2330
2331
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 471 times.
788 if(attackclk>=13)
2332 {
2333 471 wx-=1;
2334 471 wy+=1;
2335 471 ++t;
2336 471 }
2337
2338
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 417 times.
788 if(attackclk>=15)
2339 {
2340
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if (IsSideSwim())wy-=hammer_swim_up_offset;
2341 417 ++t;
2342 417 }
2343
2344 788 break;
2345
2346 case down:
2347 510 wx=3;
2348 510 wy=-14;
2349
1/2
✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
510 if (IsSideSwim())wy+=hammer_swim_down_offset;
2350 510 t+=3;
2351
2352
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 306 times.
510 if(attackclk>=13)
2353 {
2354 306 wy+=16;
2355 306 ++t;
2356 306 }
2357
2358
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 272 times.
510 if(attackclk>=15)
2359 {
2360 272 wx-=1;
2361 272 wy+=12;
2362
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 if (IsSideSwim())wy-=hammer_swim_down_offset;
2363 272 ++t;
2364 272 }
2365
2366 510 break;
2367
2368 case left:
2369 123 wx=0;
2370 123 wy=-14;
2371
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if (IsSideSwim())wy+=hammer_swim_left_offset;
2372 123 t+=6;
2373 123 f=1;
2374
2375
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 75 times.
123 if(attackclk>=13)
2376 {
2377 75 wx-=7;
2378 75 wy+=8;
2379 75 ++t;
2380 75 }
2381
2382
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 67 times.
123 if(attackclk>=15)
2383 {
2384 67 wx-=8;
2385 67 wy+=8;
2386
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if (IsSideSwim())wy-=hammer_swim_left_offset;
2387 67 ++t;
2388 67 }
2389
2390 123 break;
2391
2392 case right:
2393 1178 wx=0;
2394 1178 wy=-14;
2395
1/2
✓ Branch 0 taken 1178 times.
✗ Branch 1 not taken.
1178 if (IsSideSwim())wy+=hammer_swim_right_offset;
2396 1178 t+=6;
2397
2398
2/2
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 696 times.
1178 if(attackclk>=13)
2399 {
2400 696 wx+=7;
2401 696 wy+=8;
2402 696 ++t;
2403 696 }
2404
2405
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 620 times.
1178 if(attackclk>=15)
2406 {
2407 620 wx+=8;
2408 620 wy+=8;
2409
1/2
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
620 if (IsSideSwim())wy-=hammer_swim_right_offset;
2410 620 ++t;
2411 620 }
2412
2413 1178 break;
2414 }
2415
2416
6/8
✓ Branch 0 taken 2539 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 1770 times.
✓ Branch 3 taken 769 times.
✓ Branch 4 taken 1770 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1770 times.
✗ Branch 7 not taken.
2599 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2417 {
2418 60 wy+=2;
2419 60 }
2420
2421 // Stone of Agony
2422
1/2
✓ Branch 0 taken 2599 times.
✗ Branch 1 not taken.
2599 if(agony)
2423 {
2424 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2425 }
2426
2427 2599 w->x = x+wx;
2428 2599 w->y = y+wy-(54-yofs)-fakez;
2429 2599 w->z = (z+zofs);
2430 2599 w->tile = t;
2431 2599 w->flip = f;
2432 2599 w->hxsz=20;
2433 2599 w->hysz=20;
2434
2435
2/2
✓ Branch 0 taken 1301 times.
✓ Branch 1 taken 1298 times.
2599 if(dir>down)
2436 {
2437 1301 w->hysz-=6;
2438 1301 }
2439 else
2440 {
2441 1298 w->hxsz-=6;
2442 1298 w->hyofs=4;
2443 }
2444
2445 2599 w->power = weaponattackpower(itemid);
2446
2447
5/10
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 2513 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 86 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2599 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2448 {
2449
2/4
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
86 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2450 86 }
2451
2452 2599 xofs=oxofs;
2453 2599 yofs=oyofs;
2454 2599 return;
2455 }
2456 93353 }
2457
2/4
✓ Branch 0 taken 3681359 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3681359 times.
3681359 else if(!charging && !spins) // remove the sword
2458 {
2459
2/2
✓ Branch 0 taken 1304232 times.
✓ Branch 1 taken 3681359 times.
4985591 for(int32_t i=0; i<Lwpns.Count(); i++)
2460 {
2461 1304232 weapon *w = (weapon*)Lwpns.spr(i);
2462
2463
5/6
✓ Branch 0 taken 1303582 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 1303582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17120 times.
✓ Branch 5 taken 1286462 times.
1304232 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2464 17770 w->dead=1;
2465 1304232 }
2466 3681359 }
2467
2468
2/2
✓ Branch 0 taken 25928 times.
✓ Branch 1 taken 3748784 times.
3774712 if(invisible)
2469 {
2470 25928 xofs=oxofs;
2471 25928 yofs=oyofs;
2472 25928 return;
2473 }
2474
2475
2/4
✓ Branch 0 taken 3748784 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3748784 times.
3748784 if(action != casting && action != sideswimcasting)
2476 {
2477 // Keep this consistent with checkspecial2, line 7800-ish...
2478
6/6
✓ Branch 0 taken 79541 times.
✓ Branch 1 taken 3669243 times.
✓ Branch 2 taken 74117 times.
✓ Branch 3 taken 5424 times.
✓ Branch 4 taken 5754 times.
✓ Branch 5 taken 68363 times.
3748784 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2479
2480 3748784 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2481 3748784 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2482 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2483
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3506132 times.
✓ Branch 3 taken 242652 times.
3748784 switch(zinit.heroAnimationStyle)
2484 {
2485 case las_original: //normal
2486
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 3506068 times.
3506132 if(action==drowning)
2487 {
2488
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(inwater)
2489 {
2490 64 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2492 64 }
2493 else
2494 {
2495 xofs=oxofs;
2496 yofs=oyofs;
2497 return;
2498 }
2499 64 }
2500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3506068 times.
3506068 else if(action==lavadrowning)
2501 {
2502 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2503 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2504 }
2505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3506068 times.
3506068 else if(action==sidedrowning)
2506 {
2507 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2508 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2509 }
2510
2/4
✓ Branch 0 taken 3506068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3506068 times.
3506068 else if (action == sideswimming || action == sideswimhit)
2511 {
2512 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2513
2514 if(lstep>=6)
2515 {
2516 if(dir==up)
2517 {
2518 if ( script_hero_sprite <= 0 ) ++flip;
2519 }
2520 else
2521 {
2522 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2523 }
2524 }
2525 }
2526
5/6
✓ Branch 0 taken 3482040 times.
✓ Branch 1 taken 24028 times.
✓ Branch 2 taken 3481860 times.
✓ Branch 3 taken 180 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3481860 times.
3506068 else if(action==swimming || action==swimhit || hopclk==0xFF)
2527 {
2528 24208 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2529
2530
2/2
✓ Branch 0 taken 12228 times.
✓ Branch 1 taken 11980 times.
24208 if(lstep>=6)
2531 {
2532
2/2
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 10309 times.
11980 if(dir==up)
2533 {
2534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1671 times.
1671 if ( script_hero_sprite <= 0 ) ++flip;
2535 1671 }
2536 else
2537 {
2538
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10309 times.
10309 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2539 }
2540 11980 }
2541
2542
2/2
✓ Branch 0 taken 22503 times.
✓ Branch 1 taken 1705 times.
24208 if(isDiving())
2543 {
2544 1705 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1705 times.
1705 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2546 1705 }
2547 24208 }
2548
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 3480242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
3481860 else if(charging > 0 && attack != wHammer)
2549 {
2550 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2551
2552
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2553 {
2554
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2555 {
2556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( script_hero_sprite <= 0 ) ++flip;
2557 144 }
2558 else
2559 {
2560
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2561 }
2562 675 }
2563 1618 }
2564
9/12
✓ Branch 0 taken 3480000 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 3480000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 3394437 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
3480242 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2565 {
2566 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2568 71761 }
2569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3408481 times.
3408481 else if(fallclk>0)
2570 {
2571 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2572 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2573 }
2574
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 3407865 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3408481 else if(!noliftspr&&action==lifting&&isLifting())
2575 {
2576 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2577 if(script_hero_sprite <= 0)
2578 {
2579 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2580 auto speed = tliftclk/frames;
2581 if (speed < 1) speed = 1;
2582 auto curframe = (tliftclk - liftclk) / speed;
2583 if (!tliftclk) curframe = frames - 1;
2584 if(unsigned(curframe) < frames)
2585 tile += curframe * (extend == 2 ? 2 : 1);
2586 }
2587 }
2588 else
2589 {
2590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3408481 times.
3408481 if(IsSideSwim())
2591 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2592
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 3407865 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
3408481 else if(!noliftspr&&isLifting())
2593 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2594 3408481 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2595
2596
2/2
✓ Branch 0 taken 2538270 times.
✓ Branch 1 taken 870211 times.
3408481 if(dir>up)
2597 {
2598 2538270 useltm=true;
2599 2538270 shieldModify=true;
2600 2538270 }
2601
2602
2/2
✓ Branch 0 taken 1640593 times.
✓ Branch 1 taken 1767888 times.
3408481 if(lstep>=6)
2603 {
2604
2/2
✓ Branch 0 taken 444054 times.
✓ Branch 1 taken 1323834 times.
1767888 if(dir==up)
2605 {
2606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444054 times.
444054 if ( script_hero_sprite <= 0 ) ++flip;
2607 444054 }
2608 else
2609 {
2610
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1323834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1323834 times.
1323834 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2611 }
2612 1767888 }
2613 }
2614
2615 3506132 break;
2616
2617 case las_bszelda: //BS
2618
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 242012 times.
242652 if(action==drowning)
2619 {
2620
1/2
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
640 if(inwater)
2621 {
2622 640 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
640 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2624 640 }
2625 else
2626 {
2627 xofs=oxofs;
2628 yofs=oyofs;
2629 return;
2630 }
2631 640 }
2632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242012 times.
242012 else if (action == sidedrowning)
2633 {
2634 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2635 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2636 }
2637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242012 times.
242012 else if(action==lavadrowning)
2638 {
2639 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2640 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2641 }
2642
2/4
✓ Branch 0 taken 242012 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 242012 times.
242012 else if (action == sideswimming || action == sideswimhit)
2643 {
2644 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2645
2646 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2647 }
2648
4/6
✓ Branch 0 taken 240550 times.
✓ Branch 1 taken 1462 times.
✓ Branch 2 taken 240550 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 240550 times.
242012 else if(action==swimming || action==swimhit || hopclk==0xFF)
2649 {
2650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2651 {
2652 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2653 }
2654 else
2655 {
2656 1462 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2657 }
2658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2659
2660
2/2
✓ Branch 0 taken 1323 times.
✓ Branch 1 taken 139 times.
1462 if(isDiving())
2661 {
2662
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2663 {
2664 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2665 }
2666 else
2667 {
2668 139 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2669 }
2670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2671 139 }
2672 1462 }
2673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240550 else if(charging > 0 && attack != wHammer)
2674 {
2675 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2676 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2677 }
2678
8/10
✓ Branch 0 taken 237435 times.
✓ Branch 1 taken 3115 times.
✓ Branch 2 taken 237435 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2455 times.
✓ Branch 5 taken 238095 times.
✓ Branch 6 taken 1994 times.
✓ Branch 7 taken 461 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1994 times.
240550 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2679 {
2680 1994 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1994 times.
1994 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2682 1994 }
2683
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 238346 times.
238556 else if(fallclk>0)
2684 {
2685 210 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2687 210 }
2688
3/6
✓ Branch 0 taken 14313 times.
✓ Branch 1 taken 224033 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14313 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
238346 else if(!noliftspr&&action==lifting&&isLifting())
2689 {
2690 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2691 if(script_hero_sprite <= 0)
2692 {
2693 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2694 auto speed = tliftclk/frames;
2695 if (speed < 1) speed = 1;
2696 auto curframe = (tliftclk - liftclk) / speed;
2697 if (!tliftclk) curframe = frames - 1;
2698 if(unsigned(curframe) < frames)
2699 tile += curframe * (extend == 2 ? 2 : 1);
2700 }
2701 }
2702 else
2703 {
2704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 238346 times.
238346 if(IsSideSwim())
2705 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2706
3/4
✓ Branch 0 taken 14313 times.
✓ Branch 1 taken 224033 times.
✓ Branch 2 taken 14313 times.
✗ Branch 3 not taken.
238346 else if(!noliftspr&&isLifting())
2707 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2708 238346 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2709
2710
2/2
✓ Branch 0 taken 77744 times.
✓ Branch 1 taken 160602 times.
238346 if(dir>up)
2711 {
2712 160602 useltm=true;
2713 160602 shieldModify=true;
2714 160602 }
2715
2716 /*
2717 else if (dir==up)
2718 {
2719 useltm=true;
2720 }
2721 */
2722
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 235786 times.
238346 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2723 }
2724
2725 242652 break;
2726
2727 case las_zelda3slow: //8-frame Zelda 3 (slow)
2728 case las_zelda3: //8-frame Zelda 3
2729 if(action == drowning)
2730 {
2731 if(inwater)
2732 {
2733 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2734 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2735 }
2736 else
2737 {
2738 xofs=oxofs;
2739 yofs=oyofs;
2740 return;
2741 }
2742 }
2743 else if(action == lavadrowning)
2744 {
2745 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2746 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2747
2748 }
2749 else if(action == sidedrowning)
2750 {
2751 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2752 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2753 }
2754 else if (action == sideswimming || action == sideswimhit)
2755 {
2756 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2757
2758 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2759 }
2760 else if(action == swimming || action==swimhit || hopclk==0xFF)
2761 {
2762 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2763 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2764
2765 if(isDiving())
2766 {
2767 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2768 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2769 }
2770 }
2771 else if(charging > 0 && attack != wHammer)
2772 {
2773 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2774 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2775 //int32_t l=hero_count/hero_animation_speed;
2776 int32_t l=(hero_count/hero_animation_speed)&15;
2777 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2778 l-=((l>3)?1:0)+((l>12)?1:0);
2779 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2780 }
2781 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2782 {
2783 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2784 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2785 }
2786 else if(fallclk>0)
2787 {
2788 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2789 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2790 }
2791 else if(!noliftspr&&action==lifting&&isLifting())
2792 {
2793 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2794 if(script_hero_sprite <= 0)
2795 {
2796 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2797 auto speed = tliftclk/frames;
2798 if (speed < 1) speed = 1;
2799 auto curframe = (tliftclk-liftclk)/speed;
2800 if (!tliftclk) curframe = frames - 1;
2801 if(unsigned(curframe) < frames)
2802 tile += curframe * (extend == 2 ? 2 : 1);
2803 }
2804 }
2805 else
2806 {
2807 if(IsSideSwim())
2808 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2809 else if(!noliftspr&&isLifting())
2810 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2811 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2812
2813 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2814 {
2815 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2816 }
2817
2818 if(dir>up)
2819 {
2820 useltm=true;
2821 shieldModify=true;
2822 }
2823
2824 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2825 {
2826 //tile+=(extend==2?2:1);
2827 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2828 int32_t l = hero_count / hero_animation_speed;
2829 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2830 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2831 }
2832 }
2833
2834 break;
2835
2836 default:
2837 break;
2838 }
2839 3748784 }
2840
2841
6/6
✓ Branch 0 taken 3195187 times.
✓ Branch 1 taken 553597 times.
✓ Branch 2 taken 2262213 times.
✓ Branch 3 taken 932974 times.
✓ Branch 4 taken 120151 times.
✓ Branch 5 taken 2142062 times.
3748784 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2842
2843
2/2
✓ Branch 0 taken 3747316 times.
✓ Branch 1 taken 1468 times.
3748784 if(action==won)
2844 {
2845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1468 times.
1468 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2846 1468 }
2847
2848
4/4
✓ Branch 0 taken 3715634 times.
✓ Branch 1 taken 33150 times.
✓ Branch 2 taken 30668 times.
✓ Branch 3 taken 3684966 times.
3748784 if(action==landhold1 || action==landhold2)
2849 {
2850 63818 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2851
6/6
✓ Branch 0 taken 52500 times.
✓ Branch 1 taken 11318 times.
✓ Branch 2 taken 38865 times.
✓ Branch 3 taken 13635 times.
✓ Branch 4 taken 12007 times.
✓ Branch 5 taken 26858 times.
63818 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2852 63818 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2853 63818 }
2854
4/4
✓ Branch 0 taken 3684576 times.
✓ Branch 1 taken 390 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 3684446 times.
3684966 else if(action==waterhold1 || action==waterhold2)
2855 {
2856 520 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2857 520 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2858 520 }
2859
2/4
✓ Branch 0 taken 3684446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3684446 times.
3684446 else if(action==sidewaterhold1 || action==sidewaterhold2)
2860 {
2861 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2862 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2863 }
2864
2865
2/4
✓ Branch 0 taken 3748784 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3748784 times.
3748784 if(action!=casting && action!=sideswimcasting)
2866 {
2867
2/2
✓ Branch 0 taken 893469 times.
✓ Branch 1 taken 2855315 times.
3748784 if(useltm)
2868 {
2869
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 2852755 times.
2855315 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2870 2855315 }
2871 3748784 }
2872
2873 // Stone of Agony
2874
2/2
✓ Branch 0 taken 3748752 times.
✓ Branch 1 taken 32 times.
3748784 if(agony)
2875 {
2876
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2877 32 }
2878
2879
6/6
✓ Branch 0 taken 1163356 times.
✓ Branch 1 taken 2585428 times.
✓ Branch 2 taken 1108839 times.
✓ Branch 3 taken 54517 times.
✓ Branch 4 taken 59060 times.
✓ Branch 5 taken 1104296 times.
3748784 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2880 {
2881 3689724 masked_draw(dest);
2882 3689724 }
2883
2884 //draw held items after Hero so they don't go behind his head
2885
4/4
✓ Branch 0 taken 3715634 times.
✓ Branch 1 taken 33150 times.
✓ Branch 2 taken 30668 times.
✓ Branch 3 taken 3684966 times.
3748784 if(action==landhold1 || action==landhold2)
2886 {
2887
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 63810 times.
63818 if(holditem > -1)
2888 {
2889
2/2
✓ Branch 0 taken 31251 times.
✓ Branch 1 taken 32559 times.
63810 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2890 {
2891 31251 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2892 31251 }
2893 else
2894 {
2895 32559 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2896 }
2897 63810 }
2898 63818 }
2899
4/4
✓ Branch 0 taken 3684576 times.
✓ Branch 1 taken 390 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 3684446 times.
3684966 else if(action==waterhold1 || action==waterhold2)
2900 {
2901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520 times.
520 if(holditem > -1)
2902 {
2903
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 260 times.
520 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2904 {
2905 260 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2906 260 }
2907 else
2908 {
2909 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2910 }
2911 520 }
2912 520 }
2913
2/4
✓ Branch 0 taken 3684446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3684446 times.
3684446 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2914 {
2915 if(holditem > -1)
2916 {
2917 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2918 {
2919 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2920 }
2921 else
2922 {
2923 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2924 }
2925 }
2926 }
2927
3/4
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 3737233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11551 times.
3748784 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2928 {
2929 3737233 xofs=oxofs;
2930 3737233 yofs=oyofs;
2931 3737233 return;
2932 }
2933
2934 11551 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2935 11551 int32_t hearts=0;
2936 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2937 11551 int32_t htile = 2;
2938
2939 11551 do
2940 {
2941 72528 int32_t nx=125;
2942
2943
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 21360 times.
72528 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2944 {
2945 21360 nx=x;
2946 21360 }
2947
2948 72528 int32_t ny=88;
2949
2950
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 21360 times.
72528 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2951 {
2952 21360 ny=y;
2953 21360 }
2954
2955 72528 double tx = zc::math::Cos(a2)*53 +nx;
2956 72528 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2957 72528 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2958 72528 a2-=PI/4;
2959 72528 ++hearts;
2960
2/2
✓ Branch 0 taken 60977 times.
✓ Branch 1 taken 11551 times.
145056 }
2961
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 66848 times.
72528 while(a2>PI/2 && hearts<8);
2962
2963 11551 xofs=oxofs;
2964 11551 yofs=oyofs;
2965 4213615 }
2966
2967 4115749 void HeroClass::masked_draw(BITMAP* dest)
2968 {
2969
12/12
✓ Branch 0 taken 2525270 times.
✓ Branch 1 taken 1590479 times.
✓ Branch 2 taken 2396295 times.
✓ Branch 3 taken 128975 times.
✓ Branch 4 taken 2361840 times.
✓ Branch 5 taken 34455 times.
✓ Branch 6 taken 2324877 times.
✓ Branch 7 taken 36963 times.
✓ Branch 8 taken 2272875 times.
✓ Branch 9 taken 52002 times.
✓ Branch 10 taken 2334178 times.
✓ Branch 11 taken 62117 times.
4115749 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
2970 {
2971 // clip under doorways
2972 62117 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
2973
2974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62117 times.
62117 if(sub!=NULL)
2975 {
2976 62117 yofs -= (playing_field_offset+16);
2977 62117 xofs -= 16;
2978 62117 sprite::draw(sub);
2979
1/2
✓ Branch 0 taken 62117 times.
✗ Branch 1 not taken.
62117 if(lift_wpn)
2980 {
2981 handle_lift(false);
2982 bool shad = lift_wpn->has_shadow;
2983 lift_wpn->has_shadow = false;
2984 lift_wpn->draw(sub);
2985 lift_wpn->has_shadow = shad;
2986 }
2987 62117 prompt_draw(sub);
2988 62117 xofs+=16;
2989 62117 yofs += (playing_field_offset+16);
2990 62117 destroy_bitmap(sub);
2991 62117 }
2992 62117 }
2993 else
2994 {
2995 4053632 sprite::draw(dest);
2996
1/2
✓ Branch 0 taken 4053632 times.
✗ Branch 1 not taken.
4053632 if(lift_wpn)
2997 {
2998 handle_lift(false);
2999 bool shad = lift_wpn->has_shadow;
3000 lift_wpn->has_shadow = false;
3001 lift_wpn->draw(dest);
3002 lift_wpn->has_shadow = shad;
3003 }
3004 4053632 prompt_draw(dest);
3005 }
3006
3007 4115749 return;
3008 }
3009 4115749 void HeroClass::prompt_draw(BITMAP* dest)
3010 {
3011
2/2
✓ Branch 0 taken 4114253 times.
✓ Branch 1 taken 1496 times.
4115749 if(!prompt_combo) return;
3012 1496 int32_t sx = real_x(x+xofs+prompt_x);
3013 1496 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3014 1496 sy -= fake_z(fakez);
3015 1496 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3016 1496 return;
3017 4115749 }
3018
3019 5957 void collectitem_script(int32_t id)
3020 {
3021
2/2
✓ Branch 0 taken 5858 times.
✓ Branch 1 taken 99 times.
5957 if(itemsbuf[id].collect_script)
3022 {
3023 //clear item script stack.
3024 //ri = &(itemScriptData[id]);
3025 //ri->Clear();
3026 //itemCollectScriptData[id].Clear();
3027 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3028 99 ri = &(itemCollectScriptData[id]);
3029
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 99 times.
101475 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3030 99 ri->Clear();
3031 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3032
3033
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3034 {
3035 99 item_collect_doscript[id] = 1;
3036 99 itemscriptInitialised[id] = 0;
3037 99 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3038 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3039 99 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3040 99 }
3041 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3042 {
3043 item_collect_doscript[id] = 1;
3044 itemscriptInitialised[id] = 0;
3045 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3046 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3047 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3048 }
3049 //runningItemScripts[id] = 0;
3050 99 }
3051 5957 }
3052 528 void passiveitem_script(int32_t id, bool doRun = false)
3053 {
3054 //Passive item scripts on colelction
3055
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3056 {
3057 ri = &(itemScriptData[id]);
3058 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3059 ri->Clear();
3060 item_doscript[id] = 1;
3061 itemscriptInitialised[id] = 0;
3062
3063
3064 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3065 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3066 {
3067 item_doscript[id] = 0;
3068 return;
3069 }
3070 if(doRun)
3071 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3072 }
3073 528 }
3074
3075 // separate case for sword/wand/hammer/slashed weapons only
3076 // the main weapon checking is in the global function check_collisions()
3077 3628643 bool HeroClass::checkstab()
3078 {
3079
13/14
✓ Branch 0 taken 3103657 times.
✓ Branch 1 taken 524986 times.
✓ Branch 2 taken 120412 times.
✓ Branch 3 taken 404574 times.
✓ Branch 4 taken 103804 times.
✓ Branch 5 taken 16608 times.
✓ Branch 6 taken 101205 times.
✓ Branch 7 taken 2599 times.
✓ Branch 8 taken 101205 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 90722 times.
✓ Branch 11 taken 10483 times.
✓ Branch 12 taken 126584 times.
✓ Branch 13 taken 307680 times.
3628643 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3080 524986 || (attackclk<=4))
3081 3320963 return false;
3082
3083 307680 weapon *w=NULL;
3084
3085 307680 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3086 307680 bool found = false;
3087 307680 int32_t melee_weapon_index = 0;
3088 307680 int32_t parentitem=-1;
3089 307680 weapon* meleeweap = nullptr;
3090
2/2
✓ Branch 0 taken 33670 times.
✓ Branch 1 taken 365384 times.
399054 for(int32_t i=0; i<Lwpns.Count(); i++)
3091 {
3092 365384 w = (weapon*)Lwpns.spr(i);
3093
3094
5/6
✓ Branch 0 taken 365384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9719 times.
✓ Branch 3 taken 355665 times.
✓ Branch 4 taken 91374 times.
✓ Branch 5 taken 274010 times.
365384 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3095 {
3096 274010 found = true;
3097 274010 melee_weapon_index = i+1;
3098 274010 meleeweap = w;
3099 // Position the sword as Hero slashes with it.
3100
3/4
✓ Branch 0 taken 271759 times.
✓ Branch 1 taken 2251 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 271759 times.
274010 if(w->id!=wHammer&&w->id!=wBugNet)
3101 271759 positionSword(w,w->parentitem);
3102
3103 274010 wx=w->x;
3104 274010 wy=w->y;
3105 274010 wz=w->z;
3106 274010 wxsz = w->hxsz;
3107 274010 wysz = w->hysz;
3108 274010 parentitem = w->parentitem;
3109 274010 break;
3110 }
3111 91374 }
3112
3113
6/6
✓ Branch 0 taken 286417 times.
✓ Branch 1 taken 21263 times.
✓ Branch 2 taken 29914 times.
✓ Branch 3 taken 256503 times.
✓ Branch 4 taken 1806 times.
✓ Branch 5 taken 28108 times.
307680 if(attack==wSword && attackclk>=14 && charging==0)
3114 28108 return false;
3115
3116
2/2
✓ Branch 0 taken 245902 times.
✓ Branch 1 taken 33670 times.
279572 if(!found)
3117 33670 return false;
3118
3119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245902 times.
245902 if(attack == wFire)
3120 return false;
3121
3122
2/2
✓ Branch 0 taken 243651 times.
✓ Branch 1 taken 2251 times.
245902 if(attack==wHammer)
3123 {
3124
2/2
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 1376 times.
2251 if(attackclk<15)
3125 {
3126
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 40 times.
✓ Branch 4 taken 405 times.
875 switch(w->dir)
3127 {
3128 case up:
3129 260 wx=x-1;
3130 260 wy=y-4;
3131 260 break;
3132
3133 case down:
3134 170 wx=x+8;
3135 170 wy=y+28;
3136 170 break; // This is consistent with 2.10
3137
3138 case left:
3139 40 wx=x-13;
3140 40 wy=y+14;
3141 40 break;
3142
3143 case right:
3144 405 wx=x+21;
3145 405 wy=y+14;
3146 405 break;
3147 }
3148
3149
5/8
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 789 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 86 times.
875 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3150 {
3151 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3152 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3153 switch(dir)
3154 {
3155 case up:
3156 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3157 break;
3158
3159 case down:
3160 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3161 break;
3162
3163 case left:
3164 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3165 break;
3166
3167 case right:
3168 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3169 break;
3170 }
3171 */
3172 86 }
3173
3174 875 return false;
3175 }
3176
2/2
✓ Branch 0 taken 1290 times.
✓ Branch 1 taken 86 times.
1376 else if(attackclk==15)
3177 {
3178 // Hammer's reach needs adjusted slightly for backward compatibility
3179
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 26 times.
86 if(w->dir==up)
3180 26 w->hyofs-=1;
3181
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 4 times.
60 else if(w->dir==left)
3182 4 w->hxofs-=2;
3183 86 }
3184 1376 }
3185
3186 // The return of Spaghetti Code Constants!
3187
5/6
✓ Branch 0 taken 10628 times.
✓ Branch 1 taken 234399 times.
✓ Branch 2 taken 233023 times.
✓ Branch 3 taken 1376 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1376 times.
245027 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3188
3/4
✓ Branch 0 taken 17374 times.
✓ Branch 1 taken 227653 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17374 times.
245027 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3189 245027 itemid = vbound(itemid, 0, MAXITEMS-1);
3190
3191 // The sword offsets aren't based on anything other than what felt about right
3192 // compared to the NES game and what mostly kept it from hitting things that
3193 // should clearly be out of range. They could probably still use more tweaking.
3194 // Don't use 2.10 for reference; it's pretty far off.
3195 // - Saf
3196
3197
6/6
✓ Branch 0 taken 34190 times.
✓ Branch 1 taken 210837 times.
✓ Branch 2 taken 5327 times.
✓ Branch 3 taken 28863 times.
✓ Branch 4 taken 8134 times.
✓ Branch 5 taken 26056 times.
245027 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3198 {
3199
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4204 times.
✓ Branch 2 taken 6630 times.
✓ Branch 3 taken 7778 times.
✓ Branch 4 taken 7444 times.
26056 switch(w->dir)
3200 {
3201 case up:
3202
2/2
✓ Branch 0 taken 2711 times.
✓ Branch 1 taken 1493 times.
4204 if(attackclk<8)
3203 {
3204 1493 wy-=4;
3205 1493 }
3206
3207 4204 break;
3208
3209 case down:
3210 //if(attackclk<8)
3211 {
3212 6630 wy-=2;
3213 }
3214 6630 break;
3215
3216 case left:
3217
3218 //if(attackclk<8)
3219 {
3220 7778 wx+=2;
3221 }
3222
3223 7778 break;
3224
3225 case right:
3226
3227 //if(attackclk<8)
3228 {
3229 7444 wx-=3;
3230 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3231 }
3232
3233 7444 break;
3234 }
3235 26056 }
3236
3237
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 52282 times.
✓ Branch 2 taken 53429 times.
✓ Branch 3 taken 69504 times.
✓ Branch 4 taken 69812 times.
245027 switch(w->dir)
3238 {
3239 case up:
3240 52282 wx+=2;
3241 52282 break;
3242
3243 case down:
3244 53429 break;
3245
3246 case left:
3247 69504 wy-=3;
3248 69504 break;
3249
3250 case right:
3251 69812 wy-=3;
3252 69812 break;
3253 }
3254
3255 245027 wx+=w->hxofs;
3256 245027 wy+=w->hyofs;
3257 245027 wy-=(w->fakez).getInt();
3258
3259
2/2
✓ Branch 0 taken 242549 times.
✓ Branch 1 taken 1299508 times.
1542057 for(int32_t i=0; i<guys.Count(); i++)
3260 {
3261
1/2
✓ Branch 0 taken 1299508 times.
✗ Branch 1 not taken.
1299508 if(attack==wBugNet) break;
3262 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3263
6/6
✓ Branch 0 taken 25018 times.
✓ Branch 1 taken 1274490 times.
✓ Branch 2 taken 24607 times.
✓ Branch 3 taken 411 times.
✓ Branch 4 taken 24506 times.
✓ Branch 5 taken 101 times.
1299534 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3264
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 226 times.
✓ Branch 2 taken 1190495 times.
✓ Branch 3 taken 84281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1274776 times.
1275002 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3265
4/4
✓ Branch 0 taken 4903 times.
✓ Branch 1 taken 1269873 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 4877 times.
1274776 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3266 {
3267 // Checking the whimsical ring for every collision check causes
3268 // an odd bug. It's much more likely to activate on a 0-damage
3269 // weapon, since a 0-damage hit won't make the enemy invulnerable
3270 // to damaging hits in the following frames.
3271
3272 24732 int32_t whimsyid = current_item_id(itype_whimsicalring);
3273
3274 24732 int32_t dmg = weaponattackpower(itemid);
3275
2/2
✓ Branch 0 taken 22831 times.
✓ Branch 1 taken 1901 times.
24732 if(whimsyid>-1)
3276 {
3277
3/4
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 1786 times.
1901 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3278 115 dmg += current_item_power(itype_whimsicalring);
3279 1786 else whimsyid = -1;
3280 1901 }
3281 24732 int32_t atkringid = current_item_id(itype_atkring);
3282
1/2
✓ Branch 0 taken 24732 times.
✗ Branch 1 not taken.
24732 if(atkringid>-1)
3283 {
3284 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3285 dmg += itemsbuf[atkringid].misc1; //Additive
3286 }
3287
3288 24732 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn);
3289 24732 enemy *e = (enemy*)guys.spr(i);
3290
2/2
✓ Branch 0 taken 8869 times.
✓ Branch 1 taken 15863 times.
24732 if (h == -1) { e->hitby[HIT_BY_LWEAPON] = melee_weapon_index; } //temp_hit = true; }
3291 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3292
3293
4/4
✓ Branch 0 taken 15863 times.
✓ Branch 1 taken 8869 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 15818 times.
24732 if(h<0 && whimsyid>-1)
3294 {
3295 45 sfx(itemsbuf[whimsyid].usesound);
3296 45 }
3297
3298
4/4
✓ Branch 0 taken 21420 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 21326 times.
✓ Branch 3 taken 94 times.
24732 if(h && charging>0)
3299 {
3300 94 attackclk = SWORDTAPFRAME;
3301 94 spins=0;
3302 94 }
3303
3304
6/8
✓ Branch 0 taken 21420 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 18170 times.
✓ Branch 3 taken 3250 times.
✓ Branch 4 taken 18170 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 18170 times.
24732 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3305 {
3306
2/2
✓ Branch 0 taken 18111 times.
✓ Branch 1 taken 59 times.
18170 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3307 {
3308 59 hithero(i);
3309 59 }
3310 18170 }
3311
3312
2/2
✓ Branch 0 taken 22254 times.
✓ Branch 1 taken 2478 times.
24732 if(h==2)
3313 2478 break;
3314 22254 }
3315 1297030 }
3316
3317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245027 times.
490054 if(attack == wBugNet
3318
2/4
✓ Branch 0 taken 245027 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 245027 times.
245027 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3319
1/2
✓ Branch 0 taken 245027 times.
✗ Branch 1 not taken.
245027 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3320 {
3321
1/4
✓ Branch 0 taken 245027 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
245027 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3322
2/2
✓ Branch 0 taken 245027 times.
✓ Branch 1 taken 63332 times.
308359 for(int32_t j=0; j<items.Count(); j++)
3323 {
3324 63332 item* ptr = (item*)items.spr(j);
3325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63332 times.
63332 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3326 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3327
3328
2/4
✓ Branch 0 taken 63332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63332 times.
✗ Branch 3 not taken.
63332 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3329 continue; //No picking these up unless you have a bottle to fill!
3330
4/6
✓ Branch 0 taken 63332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10857 times.
✓ Branch 3 taken 52475 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10857 times.
63332 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3331 {
3332
6/8
✓ Branch 0 taken 52475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19611 times.
✓ Branch 3 taken 32864 times.
✓ Branch 4 taken 32864 times.
✓ Branch 5 taken 19611 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 32864 times.
52475 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3333 {
3334
6/6
✓ Branch 0 taken 31277 times.
✓ Branch 1 taken 1587 times.
✓ Branch 2 taken 841 times.
✓ Branch 3 taken 30436 times.
✓ Branch 4 taken 31277 times.
✓ Branch 5 taken 1587 times.
64141 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3335
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 31181 times.
✓ Branch 3 taken 96 times.
31277 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3336 {
3337 1587 int32_t pickup = ptr->pickup;
3338 1587 int32_t id2 = ptr->id;
3339 1587 int32_t pstr = ptr->pstring;
3340 1587 int32_t pstr_flags = ptr->pickup_string_flags;
3341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
1587 if(!dofairy)
3342 {
3343 1587 std::vector<int32_t> &ev = FFCore.eventData;
3344 1587 ev.clear();
3345 1587 ev.push_back(id2*10000);
3346 1587 ev.push_back(pickup*10000);
3347 1587 ev.push_back(pstr*10000);
3348 1587 ev.push_back(pstr_flags*10000);
3349 1587 ev.push_back(0);
3350 1587 ev.push_back(ptr->getUID());
3351 1587 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3352 1587 ev.push_back(w->getUID());
3353
3354 1587 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3355 1587 bool nullify = ev[4] != 0;
3356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
1587 if(nullify) continue;
3357 1587 id2 = ev[0]/10000;
3358 1587 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3359 1587 pstr = ev[2] / 10000;
3360 1587 pstr_flags = ev[3] / 10000;
3361 1587 }
3362
3363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
1587 if(pickup&ipONETIME) // set mITEM for one-time-only items
3364 setmapflag(mITEM);
3365
1/2
✓ Branch 0 taken 1587 times.
✗ Branch 1 not taken.
1587 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3366 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3367
3368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1587 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3369 setxmapflag(1<<ptr->pickupexstate);
3370
1/2
✓ Branch 0 taken 1587 times.
✗ Branch 1 not taken.
1587 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3371 {
3372 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3373 hidden_entrance(0, true, false, -5);
3374 }
3375 //!DIMI
3376
3377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
1587 if(dofairy)
3378 {
3379 game->fillBottle(itemsbuf[ptr->id].misc4);
3380 }
3381 else
3382 {
3383 1587 collectitem_script(id2);
3384
3385 1587 getitem(id2, false, true);
3386 }
3387 1587 items.del(j);
3388
3389
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 1587 times.
3608 for(int32_t i=0; i<Lwpns.Count(); i++)
3390 {
3391 2021 weapon *w2 = (weapon*)Lwpns.spr(i);
3392
3393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2021 times.
2021 if(w2->dragging==j)
3394 {
3395 w2->dragging=-1;
3396 }
3397
1/2
✓ Branch 0 taken 2021 times.
✗ Branch 1 not taken.
2021 else if(w2->dragging>j)
3398 {
3399 w2->dragging-=1;
3400 }
3401 2021 }
3402
3403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1587 if ( (pstr > 0 && pstr < msg_count) )
3404 {
3405 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3406 {
3407 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3408 FFCore.SetItemMessagePlayed(id2);
3409 donewmsg(pstr);
3410 break;
3411 }
3412 }
3413
3414 1587 --j;
3415 1587 }
3416 32864 }
3417 52475 }
3418 63332 }
3419 245027 }
3420
3421
2/4
✓ Branch 0 taken 245027 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 245027 times.
245027 if(attack==wCByrna || attack==wBugNet)
3422 return false;
3423
3424
2/2
✓ Branch 0 taken 233023 times.
✓ Branch 1 taken 12004 times.
245027 if(attack==wSword)
3425 {
3426
2/2
✓ Branch 0 taken 204114 times.
✓ Branch 1 taken 28909 times.
233023 if(attackclk == 6)
3427 {
3428
2/2
✓ Branch 0 taken 5087984 times.
✓ Branch 1 taken 28909 times.
5116893 for(int32_t q=0; q<176; q++)
3429 {
3430 5087984 set_bit(screengrid,q,0);
3431 5087984 set_bit(screengrid_layer[0],q,0);
3432 5087984 set_bit(screengrid_layer[1],q,0);
3433
3434 5087984 }
3435
3436
2/2
✓ Branch 0 taken 462544 times.
✓ Branch 1 taken 28909 times.
491453 for(dword q = MAXFFCS/8; q > 0; --q)
3437 462544 ffcgrid[q-1] = 0;
3438 28909 }
3439
3440
4/4
✓ Branch 0 taken 50234 times.
✓ Branch 1 taken 182789 times.
✓ Branch 2 taken 25825 times.
✓ Branch 3 taken 24409 times.
233023 if(dir==up && ((x.getInt()&15)==0))
3441 {
3442 24409 check_slash_block(wx,wy);
3443 24409 check_slash_block(wx,wy+8);
3444
3445 //layers
3446 24409 check_slash_block_layer(wx,wy,1);
3447 24409 check_slash_block_layer(wx,wy+8,1);
3448 24409 check_slash_block_layer(wx,wy,1);
3449 24409 check_slash_block_layer(wx,wy+8,1);
3450 //2
3451 24409 check_slash_block_layer(wx,wy,2);
3452 24409 check_slash_block_layer(wx,wy+8,2);
3453 24409 check_slash_block_layer(wx,wy,2);
3454 24409 check_slash_block_layer(wx,wy+8,2);
3455
3456
3457
3458 24409 }
3459
7/8
✓ Branch 0 taken 25825 times.
✓ Branch 1 taken 182789 times.
✓ Branch 2 taken 1896 times.
✓ Branch 3 taken 23929 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 1774 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 122 times.
208614 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3460 {
3461 25703 check_slash_block(wx,wy);
3462 25703 check_slash_block(wx,wy+8);
3463 25703 check_slash_block(wx+8,wy);
3464 25703 check_slash_block(wx+8,wy+8);
3465 ///layer 1
3466 25703 check_slash_block_layer(wx,wy,1);
3467 25703 check_slash_block_layer(wx,wy+8,1);
3468 25703 check_slash_block_layer(wx+8,wy,1);
3469 25703 check_slash_block_layer(wx+8,wy+8,1);
3470 ///layer 2
3471 25703 check_slash_block_layer(wx,wy,2);
3472 25703 check_slash_block_layer(wx,wy+8,2);
3473 25703 check_slash_block_layer(wx+8,wy,2);
3474 25703 check_slash_block_layer(wx+8,wy+8,2);
3475 25703 }
3476
3477
4/4
✓ Branch 0 taken 51762 times.
✓ Branch 1 taken 181261 times.
✓ Branch 2 taken 26192 times.
✓ Branch 3 taken 25570 times.
233023 if(dir==down && ((x.getInt()&15)==0))
3478 {
3479 26192 check_slash_block(wx,wy+wysz-8);
3480 26192 check_slash_block(wx,wy+wysz);
3481
3482 //layer 1
3483 26192 check_slash_block_layer(wx,wy+wysz-8,1);
3484 26192 check_slash_block_layer(wx,wy+wysz,1);
3485 //layer 2
3486 26192 check_slash_block_layer(wx,wy+wysz-8,2);
3487 26192 check_slash_block_layer(wx,wy+wysz,2);
3488 26192 }
3489
7/8
✓ Branch 0 taken 25570 times.
✓ Branch 1 taken 181261 times.
✓ Branch 2 taken 3410 times.
✓ Branch 3 taken 22160 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 3354 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 56 times.
206831 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3490 {
3491 25514 check_slash_block(wx,wy+wysz-8);
3492 25514 check_slash_block(wx,wy+wysz);
3493 25514 check_slash_block(wx+8,wy+wysz-8);
3494 25514 check_slash_block(wx+8,wy+wysz);
3495 //layer 1
3496 25514 check_slash_block_layer(wx,wy+wysz-8,1);
3497 25514 check_slash_block_layer(wx,wy+wysz,1);
3498 25514 check_slash_block_layer(wx+8,wy+wysz-8,1);
3499 25514 check_slash_block_layer(wx+8,wy+wysz,1);
3500 //layer 2
3501 25514 check_slash_block_layer(wx,wy+wysz-8,2);
3502 25514 check_slash_block_layer(wx,wy+wysz,2);
3503 25514 check_slash_block_layer(wx+8,wy+wysz-8,2);
3504 25514 check_slash_block_layer(wx+8,wy+wysz,2);
3505 25514 }
3506
3507
2/2
✓ Branch 0 taken 168092 times.
✓ Branch 1 taken 64931 times.
233023 if(dir==left)
3508 {
3509 64931 check_slash_block(wx,wy+8);
3510 64931 check_slash_block(wx+8,wy+8);
3511 //layer 1
3512 64931 check_slash_block_layer(wx,wy+8,1);
3513 64931 check_slash_block_layer(wx+8,wy+8,1);
3514 //layer 2
3515 64931 check_slash_block_layer(wx,wy+8,2);
3516 64931 check_slash_block_layer(wx+8,wy+8,2);
3517 64931 }
3518
3519
2/2
✓ Branch 0 taken 166927 times.
✓ Branch 1 taken 66096 times.
233023 if(dir==right)
3520 {
3521 66096 check_slash_block(wx+wxsz,wy+8);
3522 66096 check_slash_block(wx+wxsz-8,wy+8);
3523 //layer 1
3524 66096 check_slash_block_layer(wx+wxsz,wy+8,1);
3525 66096 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3526 //layer 2
3527 66096 check_slash_block_layer(wx+wxsz,wy+8,2);
3528 66096 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3529 66096 }
3530 233023 }
3531
2/2
✓ Branch 0 taken 10628 times.
✓ Branch 1 taken 1376 times.
12004 else if(attack==wWand)
3532 {
3533
1/2
✓ Branch 0 taken 10628 times.
✗ Branch 1 not taken.
10628 if(attackclk == 5)
3534 {
3535 for(int32_t q=0; q<176; q++)
3536 {
3537 set_bit(screengrid,q,0);
3538 set_bit(screengrid_layer[0],q,0);
3539 set_bit(screengrid_layer[1],q,0);
3540 }
3541
3542 for(dword q = MAXFFCS/8; q > 0; --q)
3543 ffcgrid[q-1] = 0;
3544 }
3545
3546 // cutable blocks
3547
4/4
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 8996 times.
✓ Branch 2 taken 909 times.
✓ Branch 3 taken 723 times.
10628 if(dir==up && (x.getInt()&15)==0)
3548 {
3549 723 check_wand_block(wx,wy);
3550 723 check_wand_block(wx,wy+8);
3551 723 }
3552
5/8
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 8996 times.
✓ Branch 2 taken 621 times.
✓ Branch 3 taken 288 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 621 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9905 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3553 {
3554 909 check_wand_block(wx,wy);
3555 909 check_wand_block(wx,wy+8);
3556 909 check_wand_block(wx+8,wy);
3557 909 check_wand_block(wx+8,wy+8);
3558 909 }
3559
3560
4/4
✓ Branch 0 taken 1395 times.
✓ Branch 1 taken 9233 times.
✓ Branch 2 taken 654 times.
✓ Branch 3 taken 741 times.
10628 if(dir==down && (x.getInt()&15)==0)
3561 {
3562 741 check_wand_block(wx,wy+wysz-8);
3563 741 check_wand_block(wx,wy+wysz);
3564 741 }
3565
5/8
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 9233 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9887 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3566 {
3567 654 check_wand_block(wx,wy+wysz-8);
3568 654 check_wand_block(wx,wy+wysz);
3569 654 check_wand_block(wx+8,wy+wysz-8);
3570 654 check_wand_block(wx+8,wy+wysz);
3571 654 }
3572
3573
2/2
✓ Branch 0 taken 6119 times.
✓ Branch 1 taken 4509 times.
10628 if(dir==left)
3574 {
3575 4509 check_wand_block(wx,y+8);
3576 4509 check_wand_block(wx+8,y+8);
3577 4509 }
3578
3579
2/2
✓ Branch 0 taken 7536 times.
✓ Branch 1 taken 3092 times.
10628 if(dir==right)
3580 {
3581 3092 check_wand_block(wx+wxsz,y+8);
3582 3092 check_wand_block(wx+wxsz-8,y+8);
3583 3092 }
3584 10628 }
3585
4/8
✓ Branch 0 taken 1376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1290 times.
✓ Branch 3 taken 86 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1290 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1376 else if((attack==wHammer) && ((attackclk==15) || ( spins==1 && attackclk >=15 ))) //quake hammer should be spins == 1
3586 //else if((attack==wHammer) && (attackclk==15))
3587 //reverting this, because it breaks multiple-hit pegs
3588 //else if((attack==wHammer) && (attackclk>=15)) //>= instead of == for time it takes to charge up hammer with quake scrolls.
3589 {
3590 // poundable blocks
3591
2/2
✓ Branch 0 taken 15136 times.
✓ Branch 1 taken 86 times.
15222 for(int32_t q=0; q<176; q++)
3592 {
3593 15136 set_bit(screengrid,q,0);
3594 15136 set_bit(screengrid_layer[0],q,0);
3595 15136 set_bit(screengrid_layer[1],q,0);
3596 15136 }
3597
3598
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 86 times.
1462 for(dword q = MAXFFCS/8; q > 0; --q)
3599 1376 ffcgrid[q-1] = 0;
3600
3601
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 23 times.
86 if(dir==up && (x.getInt()&15)==0)
3602 {
3603 23 check_pound_block(wx,wy);
3604 23 check_pound_block(wx,wy+8);
3605 23 }
3606
3/8
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
63 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3607 {
3608 4 check_pound_block(wx,wy);
3609 4 check_pound_block(wx,wy+8);
3610 4 check_pound_block(wx+8,wy);
3611 4 check_pound_block(wx+8,wy+8);
3612 4 }
3613
3614
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 15 times.
86 if(dir==down && (x.getInt()&15)==0)
3615 {
3616 15 check_pound_block(wx,wy+wysz-8);
3617 15 check_pound_block(wx,wy+wysz);
3618 15 }
3619
3/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
71 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3620 {
3621 2 check_pound_block(wx,wy+wysz-8);
3622 2 check_pound_block(wx,wy+wysz);
3623 2 check_pound_block(wx+8,wy+wysz-8);
3624 2 check_pound_block(wx+8,wy+wysz);
3625 2 }
3626
3627
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 4 times.
86 if(dir==left)
3628 {
3629 4 check_pound_block(wx,y+8);
3630 4 check_pound_block(wx+8,y+8);
3631 4 }
3632
3633
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 38 times.
86 if(dir==right)
3634 {
3635 38 check_pound_block(wx+wxsz,y+8);
3636 38 check_pound_block(wx+wxsz-8,y+8);
3637 38 }
3638 86 }
3639 else
3640 {
3641 1290 return false;
3642 }
3643
3644 243737 return true;
3645 3628643 }
3646
3647 1233884 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3648 {
3649
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 1233508 times.
1233884 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3650 {
3651 //zprint("bit off\n");
3652 1233508 return;
3653 }
3654 //keep things inside the screen boundaries
3655 376 bx=vbound(bx, 0, 255);
3656 376 by=vbound(by, 0, 176);
3657 376 int32_t fx=vbound(bx, 0, 255);
3658 376 int32_t fy=vbound(by, 0, 176);
3659 //first things first
3660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
376 if(attack!=wSword)
3661 return;
3662
3663
3/6
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
404 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3664
3/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 348 times.
376 || (attackclk>SWORDTAPFRAME && tapping))
3665 return;
3666
3667 //find out which combo row/column the coordinates are in
3668 376 bx &= 0xF0;
3669 376 by &= 0xF0;
3670
3671
3672 376 int32_t flag = MAPFLAGL(layer,bx,by);
3673 376 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3674 376 int32_t cid = MAPCOMBOL(layer,bx,by);
3675 376 int32_t type = combobuf[cid].type;
3676
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3677 type = cNONE;
3678 //zprint("cid is: %d\n", cid);
3679 //zprint("type is: %d\n", type);
3680 376 int32_t i = (bx>>4) + by;
3681
3682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
376 if(i > 175)
3683 return;
3684
3685 376 bool ignorescreen=false;
3686
3687
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3688 376 return;
3689
3690 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3691
3692 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3693 if(isCuttableNextType(type))
3694 {
3695 FFCore.tempScreens[layer]->data[i]++;
3696 }
3697 else
3698 {
3699 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3700 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3701 FFCore.tempScreens[layer]->sflag[i] = 0;
3702 }
3703 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3704 {
3705 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3706 sfx(tmpscr->secretsfx);
3707 }
3708 else if(isCuttableItemType(type))
3709 {
3710 int32_t it = -1;
3711 int32_t thedropset = -1;
3712
3713 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3714 if ( (combobuf[cid].usrflags&cflag2) )
3715 {
3716 if(combobuf[cid].usrflags&cflag11)
3717 it = combobuf[cid].attribytes[1];
3718 else
3719 {
3720 it = select_dropitem(combobuf[cid].attribytes[1]);
3721 thedropset = combobuf[cid].attribytes[1];
3722 }
3723 }
3724 else
3725 {
3726 it = select_dropitem(12);
3727 thedropset = 12;
3728 }
3729 if(it!=-1)
3730 {
3731 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3732 itm->from_dropset = thedropset;
3733 items.add(itm);
3734 }
3735 }
3736
3737 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3738
3739 if(get_bit(quest_rules,qr_MORESOUNDS))
3740 {
3741 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3742 {
3743 if (combobuf[cid].usrflags&cflag3)
3744 {
3745 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3746 }
3747 }
3748 else
3749 {
3750 if (combobuf[cid].usrflags&cflag3)
3751 {
3752 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3753 }
3754 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3755 }
3756 }
3757
3758 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3759 if(decotype > 3) decotype = 0;
3760 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3761 switch(decotype)
3762 {
3763 case -2: break; //nothing
3764 case -1:
3765 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3766 break;
3767 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3768 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3769 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3770 }
3771 1233884 }
3772
3773 568124 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3774 {
3775 //keep things inside the screen boundaries
3776 568124 bx=vbound(bx, 0, 255);
3777 568124 by=vbound(by, 0, 176);
3778 568124 int32_t fx=vbound(bx, 0, 255);
3779 568124 int32_t fy=vbound(by, 0, 176);
3780 //first things first
3781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 568124 times.
568124 if(attack!=wSword)
3782 return;
3783
3784
4/6
✓ Branch 0 taken 568124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 568124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 67622 times.
635998 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3785
4/4
✓ Branch 0 taken 564262 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 67874 times.
✓ Branch 3 taken 496388 times.
568124 || (attackclk>SWORDTAPFRAME && tapping))
3786 4114 return;
3787
3788 //find out which combo row/column the coordinates are in
3789 564010 bx &= 0xF0;
3790 564010 by &= 0xF0;
3791
3792 564010 int32_t type = COMBOTYPE(bx,by);
3793 564010 int32_t type2 = FFCOMBOTYPE(fx,fy);
3794 564010 int32_t flag = MAPFLAG(bx,by);
3795 564010 int32_t flag2 = MAPCOMBOFLAG(bx,by);
3796 564010 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
3797 564010 int32_t cid = MAPCOMBO(bx,by);
3798 564010 int32_t i = (bx>>4) + by;
3799
3800
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 563996 times.
564010 if(i > 175)
3801 14 return;
3802
3803 563996 bool ignorescreen=false;
3804 563996 bool ignoreffc=false;
3805
3806
2/2
✓ Branch 0 taken 8211 times.
✓ Branch 1 taken 555785 times.
563996 if(get_bit(screengrid, i) != 0)
3807 {
3808 8211 ignorescreen = true;
3809 8211 }
3810
1/2
✓ Branch 0 taken 555785 times.
✗ Branch 1 not taken.
555785 else if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3811 ignorescreen = true;
3812
3813 563996 int32_t current_ffcombo = getFFCAt(fx,fy);
3814
3815
3816
3/4
✓ Branch 0 taken 3684 times.
✓ Branch 1 taken 560312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3684 times.
563996 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3817 {
3818 560312 ignoreffc = true;
3819 560312 }
3820
1/2
✓ Branch 0 taken 3684 times.
✗ Branch 1 not taken.
3684 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
3821 ignoreffc = true;
3822
3823
3/4
✓ Branch 0 taken 561468 times.
✓ Branch 1 taken 2528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 561452 times.
1125448 if(!isCuttableType(type) &&
3824
6/6
✓ Branch 0 taken 1138 times.
✓ Branch 1 taken 560330 times.
✓ Branch 2 taken 561452 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 561407 times.
561468 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3825 {
3826 561452 ignorescreen = true;
3827 561452 }
3828
3829
2/4
✓ Branch 0 taken 563996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 563996 times.
1127992 if(!isCuttableType(type2) &&
3830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563996 times.
563996 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3831 {
3832 563996 ignoreffc = true;
3833 563996 }
3834
3835 563996 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3836
3837
3/4
✓ Branch 0 taken 32952 times.
✓ Branch 1 taken 531044 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32952 times.
563996 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3838 563996 byte skipsecrets = 0;
3839
3840
2/2
✓ Branch 0 taken 561491 times.
✓ Branch 1 taken 2505 times.
563996 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3841 {
3842
2/2
✓ Branch 0 taken 2466 times.
✓ Branch 1 taken 39 times.
2505 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3843 {
3844 2466 skipsecrets = 0;
3845 2466 }
3846 39 else skipsecrets = 1; ;
3847 2505 }
3848
3849
6/6
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 562995 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 962 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 51 times.
563996 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3850 {
3851
3/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1013 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3852 {
3853 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3854 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3855 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3856 }
3857
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 else if(flag == mfARMOS_SECRET)
3858 {
3859 4 s->data[i] = s->secretcombo[sSTAIRS];
3860 4 s->cset[i] = s->secretcset[sSTAIRS];
3861 4 s->sflag[i] = s->secretflag[sSTAIRS];
3862 4 sfx(tmpscr->secretsfx);
3863 4 }
3864
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 981 times.
1009 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3865 {
3866
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 16 times.
63 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3867 {
3868 35 findentrance(bx,by,mfSWORD+i2,true);
3869 35 }
3870
3871 16 findentrance(bx,by,mfSTRIKE,true);
3872 16 }
3873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
981 else if(((flag2 >= 16)&&(flag2 <= 31)))
3874 {
3875 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3876 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3877 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3878 }
3879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
981 else if(flag2 == mfARMOS_SECRET)
3880 {
3881 s->data[i] = s->secretcombo[sSTAIRS];
3882 s->cset[i] = s->secretcset[sSTAIRS];
3883 s->sflag[i] = s->secretflag[sSTAIRS];
3884 sfx(tmpscr->secretsfx);
3885 }
3886
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 981 times.
981 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3887 {
3888 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3889 {
3890 findentrance(bx,by,mfSWORD+i2,true);
3891 }
3892
3893 findentrance(bx,by,mfSTRIKE,true);
3894 }
3895 else
3896 {
3897
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 21 times.
981 if(isCuttableNextType(type))
3898 {
3899 960 s->data[i]++;
3900 960 }
3901 else
3902 {
3903 21 s->data[i] = s->undercombo;
3904 21 s->cset[i] = s->undercset;
3905 21 s->sflag[i] = 0;
3906 }
3907
3908 //pausenow=true;
3909 }
3910 1001 }
3911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 563007 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
563007 else if(!ignorescreen && skipsecrets)
3912 {
3913 if(isCuttableNextType(type))
3914 {
3915 s->data[i]++;
3916 }
3917 else
3918 {
3919 s->data[i] = s->undercombo;
3920 s->cset[i] = s->undercset;
3921 s->sflag[i] = 0;
3922 }
3923 }
3924
3925
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 564008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 564008 times.
564008 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3926 {
3927 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3928 {
3929 findentrance(bx,by,mfSWORD+i2,true);
3930 }
3931
3932 findentrance(fx,fy,mfSTRIKE,true);
3933 }
3934
1/2
✓ Branch 0 taken 564008 times.
✗ Branch 1 not taken.
564008 else if(!ignoreffc)
3935 {
3936 if(isCuttableNextType(type2))
3937 {
3938 s->ffcs[current_ffcombo].incData(1);
3939 }
3940 else
3941 {
3942 s->ffcs[current_ffcombo].setData(s->undercombo);
3943 s->ffcs[current_ffcombo].cset = s->undercset;
3944 }
3945 }
3946
3947
2/2
✓ Branch 0 taken 563007 times.
✓ Branch 1 taken 1001 times.
564008 if(!ignorescreen)
3948 {
3949
3/4
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 955 times.
1001 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
3950
3951
5/8
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 995 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
1001 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3952 {
3953
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3954 6 sfx(tmpscr->secretsfx);
3955 6 }
3956
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 977 times.
995 else if(isCuttableItemType(type))
3957 {
3958 977 int32_t it = -1;
3959 977 int32_t thedropset = -1;
3960
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 955 times.
977 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
3961 {
3962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if ( combobuf[cid].usrflags&cflag11 )
3963 {
3964 it = combobuf[cid].attribytes[1];
3965 }
3966 else
3967 {
3968 22 it = select_dropitem(combobuf[cid].attribytes[1]);
3969 22 thedropset = combobuf[cid].attribytes[1];
3970 }
3971 22 }
3972 else
3973 {
3974 955 it = select_dropitem(12);
3975 955 thedropset = 12;
3976 }
3977
3978
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 238 times.
977 if(it!=-1)
3979 {
3980
4/8
✓ Branch 0 taken 238 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 238 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 238 times.
✗ Branch 7 not taken.
238 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3981 238 itm->from_dropset = thedropset;
3982 238 items.add(itm);
3983 238 }
3984 977 }
3985
3986 1001 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
3987
3988
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 193 times.
1001 if(get_bit(quest_rules,qr_MORESOUNDS))
3989 {
3990
6/6
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 44 times.
193 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3991 {
3992
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if (combobuf[cid].usrflags&cflag3)
3993 {
3994 22 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3995 22 }
3996 44 }
3997 else
3998 {
3999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (combobuf[cid].usrflags&cflag3)
4000 {
4001 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4002 }
4003 149 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4004 }
4005 193 }
4006
4007
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 881 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
1001 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4008
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(decotype > 3) decotype = 0;
4009
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 881 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 581 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 581 times.
✓ Branch 6 taken 531 times.
✓ Branch 7 taken 50 times.
1001 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4010
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 531 times.
1001 switch(decotype)
4011 {
4012 50 case -2: break; //nothing
4013 case -1:
4014 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4015 break;
4016
3/6
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 399 times.
✗ Branch 5 not taken.
399 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4017
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4018
3/6
✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 531 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 531 times.
✗ Branch 5 not taken.
531 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4019 }
4020 1001 }
4021
4022
1/2
✓ Branch 0 taken 564008 times.
✗ Branch 1 not taken.
564008 if(!ignoreffc)
4023 {
4024 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4025
4026 if(isCuttableItemType(type2))
4027 {
4028 int32_t it=-1;
4029 int32_t thedropset=-1;
4030 if ( (combobuf[cid].usrflags&cflag2) )
4031 {
4032 if(combobuf[cid].usrflags&cflag11)
4033 it = combobuf[cid].attribytes[1];
4034 else
4035 {
4036 it = select_dropitem(combobuf[cid].attribytes[1]);
4037 thedropset = combobuf[cid].attribytes[1];
4038 }
4039 }
4040 else
4041 {
4042 int32_t r=zc_oldrand()%100;
4043
4044 if(r<15)
4045 {
4046 it=iHeart; // 15%
4047 }
4048 else if(r<35)
4049 {
4050 it=iRupy; // 20%
4051 }
4052 }
4053
4054 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4055 {
4056 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4057 itm->from_dropset = thedropset;
4058 items.add(itm);
4059 }
4060 }
4061
4062 if(get_bit(quest_rules,qr_MORESOUNDS))
4063 {
4064 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4065 {
4066 if (combobuf[cid].usrflags&cflag3)
4067 {
4068 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4069 }
4070 }
4071 else
4072 {
4073 if (combobuf[cid].usrflags&cflag3)
4074 {
4075 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4076 }
4077 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4078 }
4079 }
4080
4081 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4082 if(decotype > 3) decotype = 0;
4083 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4084 switch(decotype)
4085 {
4086 case -2: break; //nothing
4087 case -1:
4088 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4089 break;
4090 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4091 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4092 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4093 }
4094 }
4095 568136 }
4096
4097 9918222 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4098 {
4099 /*
4100 int32_t par_item = w->parentitem;
4101 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4102 int32_t usewpn = -1;
4103 if ( par_item > -1 )
4104 {
4105 usewpn = itemsbuf[par_item].useweapon;
4106 }
4107 else if ( par_item == -1 && w->ScriptGenerated )
4108 {
4109 usewpn = w->useweapon;
4110 }
4111 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4112
4113 */
4114 9918222 bx=vbound(bx, 0, 255);
4115 9918222 by=vbound(by, 0, 176);
4116 9918222 int32_t cid = MAPCOMBO(bx,by);
4117
3/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201168 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 9715806 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1248 times.
✗ Branch 29 not taken.
9918222 switch(w->useweapon)
4118 {
4119 case wArrow:
4120 findentrance(bx,by,mfARROW,true);
4121 findentrance(bx,by,mfSARROW,true);
4122 findentrance(bx,by,mfGARROW,true);
4123 break;
4124 case wBeam:
4125 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4126 break;
4127 case wHookshot:
4128 findentrance(bx,by,mfHOOKSHOT,true);
4129 break;
4130 case wBrang:
4131 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4132 break;
4133 case wMagic:
4134 findentrance(bx,by,mfWANDMAGIC,true);
4135 break;
4136 case wRefMagic:
4137 findentrance(bx,by,mfWANDMAGIC,true);
4138 break;
4139 case wRefBeam:
4140 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4141 break;
4142 //reflected magic needs to happen in mirrors:
4143 //
4144 //findentrance(bx,by,mfREFMAGIC,true)
4145 case wRefFireball:
4146 findentrance(bx,by,mfREFFIREBALL,true);
4147 break;
4148 case wBomb:
4149 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4150 break;
4151
4152 case wSBomb:
4153 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4154 break;
4155
4156 case wFire:
4157 201168 findentrance(bx,by,mfBCANDLE,true);
4158 201168 findentrance(bx,by,mfRCANDLE,true);
4159 201168 findentrance(bx,by,mfWANDFIRE,true);
4160 /* if we want the weapon to die
4161 if (findentrance(bx,by,mfBCANDLE,true) ) dead = 1;
4162 if (findentrance(bx,by,mfRCANDLE,true) ) dead = 1;
4163 if (findentrance(bx,by,mfWANDFIRE,true)) dead = 1;
4164 */
4165 201168 break;
4166
4167 case wScript1:
4168 break;
4169 case wScript2:
4170 break;
4171 case wScript3:
4172 break;
4173 case wScript4:
4174 break;
4175 case wScript5:
4176 break;
4177 case wScript6:
4178 break;
4179 case wScript7:
4180 break;
4181 case wScript8:
4182 break;
4183 case wScript9:
4184 break;
4185 case wScript10:
4186 break;
4187 case wIce:
4188 break;
4189 case wCByrna:
4190 break;
4191 case wWhistle:
4192 break;
4193 case wSSparkle:
4194 case wFSparkle:
4195 break;
4196 case wWind:
4197 break;
4198 case wBait:
4199 break;
4200 case wFlame:
4201 case wThrown:
4202 case wBombos:
4203 case wEther:
4204 case wQuake:
4205 case wSwordLA:
4206 case wSword180:
4207 case wStomp:
4208 break;
4209 case wSword:
4210 case wWand:
4211 //case wCandle:
4212 case wHSHandle:
4213 case wLitBomb:
4214 case wLitSBomb:
4215 1248 break;
4216 9715806 default: break;
4217
4218 }
4219 9918222 }
4220
4221 19836444 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4222 {
4223
4224
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 19801884 times.
19836444 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4225 {
4226 //zprint("bit off\n");
4227 19801884 return;
4228 }
4229 //keep things inside the screen boundaries
4230 34560 bx=vbound(bx, 0, 255);
4231 34560 by=vbound(by, 0, 176);
4232 34560 int32_t fx=vbound(bx, 0, 255);
4233 34560 int32_t fy=vbound(by, 0, 176);
4234 //first things first
4235
1/2
✓ Branch 0 taken 34560 times.
✗ Branch 1 not taken.
34560 if(w->useweapon != wSword)
4236 34560 return;
4237
4238 //find out which combo row/column the coordinates are in
4239 bx &= 0xF0;
4240 by &= 0xF0;
4241
4242
4243 int32_t flag = MAPFLAGL(layer,bx,by);
4244 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4245 int32_t cid = MAPCOMBOL(layer,bx,by);
4246 int32_t type = combobuf[cid].type;
4247 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4248 type = cNONE;
4249 //zprint("cid is: %d\n", cid);
4250 //zprint("type is: %d\n", type);
4251 int32_t i = (bx>>4) + by;
4252
4253 if(i > 175)
4254 return;
4255
4256 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4257 {
4258 return;
4259 //ignorescreen = true;
4260 //zprint("ignoring\n");
4261 }
4262
4263 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4264
4265 {
4266 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4267 if(isCuttableNextType(type) || isCuttableNextType(type))
4268 {
4269 FFCore.tempScreens[layer]->data[i]++;
4270 }
4271 else
4272 {
4273 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4274 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4275 FFCore.tempScreens[layer]->sflag[i] = 0;
4276 }
4277 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4278 {
4279 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4280 sfx(tmpscr->secretsfx);
4281 }
4282 else if(isCuttableItemType(type))
4283 {
4284 int32_t it = -1;
4285 int32_t thedropset = -1;
4286
4287 if ( (combobuf[cid].usrflags&cflag2) )
4288 {
4289 if(combobuf[cid].usrflags&cflag11)
4290 it = combobuf[cid].attribytes[1];
4291 else
4292 {
4293 it = select_dropitem(combobuf[cid].attribytes[1]);
4294 thedropset = combobuf[cid].attribytes[1];
4295 }
4296 }
4297 else
4298 {
4299 it = select_dropitem(12);
4300 thedropset = 12;
4301 }
4302
4303 if(it!=-1)
4304 {
4305 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4306 itm->from_dropset = thedropset;
4307 items.add(itm);
4308 }
4309 }
4310
4311 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4312
4313 if(get_bit(quest_rules,qr_MORESOUNDS))
4314 {
4315 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4316 {
4317 if (combobuf[cid].usrflags&cflag3)
4318 {
4319 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4320 }
4321 }
4322 else
4323 {
4324 if (combobuf[cid].usrflags&cflag3)
4325 {
4326 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4327 }
4328 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4329 }
4330 }
4331
4332 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4333 if(decotype > 3) decotype = 0;
4334 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4335 switch(decotype)
4336 {
4337 case -2: break; //nothing
4338 case -1:
4339 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4340 break;
4341 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4342 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4343 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4344 }
4345
4346 }
4347
4348 19836444 }
4349
4350 9918222 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4351 {
4352 /*
4353 int32_t par_item = w->parentitem;
4354 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4355 int32_t usewpn = -1;
4356 if ( par_item > -1 )
4357 {
4358 usewpn = itemsbuf[par_item].useweapon;
4359 }
4360 else if ( par_item == -1 && w->ScriptGenerated )
4361 {
4362 usewpn = w->useweapon;
4363 }
4364 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4365 */
4366
4367
4368 //keep things inside the screen boundaries
4369 9918222 bx=vbound(bx, 0, 255);
4370 9918222 by=vbound(by, 0, 176);
4371 9918222 int32_t fx=vbound(bx, 0, 255);
4372 9918222 int32_t fy=vbound(by, 0, 176);
4373 9918222 int32_t cid = MAPCOMBO(bx,by);
4374
4375 //find out which combo row/column the coordinates are in
4376 9918222 bx &= 0xF0;
4377 9918222 by &= 0xF0;
4378
4379 9918222 int32_t type = COMBOTYPE(bx,by);
4380 9918222 int32_t type2 = FFCOMBOTYPE(fx,fy);
4381 9918222 int32_t flag = MAPFLAG(bx,by);
4382 9918222 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4383 9918222 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4384
1/2
✓ Branch 0 taken 9918222 times.
✗ Branch 1 not taken.
9918222 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4385 type = cNONE;
4386 9918222 byte dontignore = 0;
4387 9918222 byte dontignoreffc = 0;
4388
4389
4/4
✓ Branch 0 taken 175720 times.
✓ Branch 1 taken 9742502 times.
✓ Branch 2 taken 175421 times.
✓ Branch 3 taken 299 times.
9918222 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4390 {
4391 299 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4392 299 dontignore = 1;
4393 299 }
4394
4395 /*to-do, ffcs
4396 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4397 {
4398 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4399 dontignoreffc = 1;
4400 }*/
4401
4/4
✓ Branch 0 taken 9916974 times.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 9916675 times.
✓ Branch 3 taken 299 times.
9918222 if(w->useweapon != wSword && !dontignore) return;
4402
4403
4404 1547 int32_t i = (bx>>4) + by;
4405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4406
4407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if(i > 175)
4408 return;
4409
4410 1547 bool ignorescreen=false;
4411 1547 bool ignoreffc=false;
4412
4413
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(get_bit(w->wscreengrid, i) != 0)
4414 {
4415 ignorescreen = true; dontignore = 0;
4416 }
4417
4418 1547 int32_t current_ffcombo = getFFCAt(fx,fy);
4419
4420
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
1547 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4421 {
4422 1545 ignoreffc = true;
4423 1545 }
4424
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4425 type2 = cNONE;
4426
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
2795 if(!isCuttableType(type) &&
4427
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 1248 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1248 times.
1248 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4428 {
4429 1248 ignorescreen = true;
4430 1248 }
4431
4432
2/4
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
3094 if(!isCuttableType(type2) &&
4433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4434 {
4435 1547 ignoreffc = true;
4436 1547 }
4437
4438 1547 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4439
4440
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1248 times.
1547 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4441 1547 byte skipsecrets = 0;
4442
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 249 times.
1547 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4443 {
4444
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4445 {
4446 249 skipsecrets = 0;
4447 249 }
4448 else skipsecrets = 1;
4449 249 }
4450
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 949 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 1248 times.
✓ Branch 4 taken 1248 times.
✓ Branch 5 taken 949 times.
949 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4451 {
4452
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2197 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4453 {
4454 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4455 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4456 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4457 }
4458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag == mfARMOS_SECRET)
4459 {
4460 s->data[i] = s->secretcombo[sSTAIRS];
4461 s->cset[i] = s->secretcset[sSTAIRS];
4462 s->sflag[i] = s->secretflag[sSTAIRS];
4463 sfx(tmpscr->secretsfx);
4464 }
4465
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4466 {
4467 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4468 {
4469 findentrance(bx,by,mfSWORD+i2,true);
4470 }
4471
4472 findentrance(bx,by,mfSTRIKE,true);
4473 }
4474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
299 else if(((flag2 >= 16)&&(flag2 <= 31)))
4475 {
4476 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4477 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4478 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4479 }
4480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag2 == mfARMOS_SECRET)
4481 {
4482 s->data[i] = s->secretcombo[sSTAIRS];
4483 s->cset[i] = s->secretcset[sSTAIRS];
4484 s->sflag[i] = s->secretflag[sSTAIRS];
4485 sfx(tmpscr->secretsfx);
4486 }
4487
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4488 {
4489 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4490 {
4491 findentrance(bx,by,mfSWORD+i2,true);
4492 }
4493
4494 findentrance(bx,by,mfSTRIKE,true);
4495 }
4496 else
4497 {
4498
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 50 times.
299 if(isCuttableNextType(type))
4499 {
4500 249 s->data[i]++;
4501 249 }
4502 else
4503 {
4504 50 s->data[i] = s->undercombo;
4505 50 s->cset[i] = s->undercset;
4506 50 s->sflag[i] = 0;
4507 }
4508
4509 //pausenow=true;
4510 }
4511 299 }
4512
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1248 else if(skipsecrets && (!ignorescreen || dontignore))
4513 {
4514 if(isCuttableNextType(type))
4515 {
4516 s->data[i]++;
4517 }
4518 else
4519 {
4520 s->data[i] = s->undercombo;
4521 s->cset[i] = s->undercset;
4522 s->sflag[i] = 0;
4523 }
4524 }
4525
4526
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
1547 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4527 {
4528 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4529 {
4530 findentrance(bx,by,mfSWORD+i2,true);
4531 }
4532
4533 findentrance(fx,fy,mfSTRIKE,true);
4534 }
4535
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 else if(!ignoreffc)
4536 {
4537 if(isCuttableNextType(type2))
4538 {
4539 s->ffcs[current_ffcombo].incData(1);
4540 }
4541 else
4542 {
4543 s->ffcs[current_ffcombo].setData(s->undercombo);
4544 s->ffcs[current_ffcombo].cset = s->undercset;
4545 }
4546 }
4547
4548
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1547 if(!ignorescreen || dontignore)
4549 {
4550
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
299 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4551
4552
2/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4553 {
4554 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4555 sfx(tmpscr->secretsfx);
4556 }
4557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(isCuttableItemType(type))
4558 {
4559 299 int32_t it = -1;
4560 299 int32_t thedropset = -1;
4561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4562 {
4563 if ( combobuf[cid].usrflags&cflag11 )
4564 {
4565 it = combobuf[cid].attribytes[1];
4566 }
4567 else
4568 {
4569 it = select_dropitem(combobuf[cid].attribytes[1]);
4570 thedropset = combobuf[cid].attribytes[1];
4571 }
4572 }
4573 else
4574 {
4575 299 it = select_dropitem(12);
4576 299 thedropset = 12;
4577 }
4578
4579
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(it!=-1)
4580 {
4581
4/8
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
99 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4582 99 itm->from_dropset = thedropset;
4583 99 items.add(itm);
4584 99 }
4585 299 }
4586
4587
4588 299 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4589
4590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(get_bit(quest_rules,qr_MORESOUNDS))
4591 {
4592
5/6
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4593 {
4594 if (combobuf[cid].usrflags&cflag3)
4595 {
4596 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4597 }
4598 }
4599 else
4600 {
4601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (combobuf[cid].usrflags&cflag3)
4602 {
4603 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4604 }
4605 299 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4606 }
4607 299 }
4608
4609
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
299 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4610
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(decotype > 3) decotype = 0;
4611
1/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4612
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
299 switch(decotype)
4613 {
4614 case -2: break; //nothing
4615 case -1:
4616 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4617 break;
4618
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4619
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4620 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4621 }
4622 299 }
4623
4624
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(!ignoreffc)
4625 {
4626 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4627
4628 if(isCuttableItemType(type2))
4629 {
4630 int32_t it=-1;
4631 int32_t thedropset=-1;
4632 if ( (combobuf[cid].usrflags&cflag2) )
4633 {
4634 if(combobuf[cid].usrflags&cflag11)
4635 it = combobuf[cid].attribytes[1];
4636 else
4637 {
4638 it = select_dropitem(combobuf[cid].attribytes[1]);
4639 thedropset = combobuf[cid].attribytes[1];
4640 }
4641 }
4642 else
4643 {
4644 int32_t r=zc_oldrand()%100;
4645
4646 if(r<15)
4647 {
4648 it=iHeart; // 15%
4649 }
4650 else if(r<35)
4651 {
4652 it=iRupy; // 20%
4653 }
4654 }
4655
4656 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4657 {
4658 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4659 itm->from_dropset = thedropset;
4660 items.add(itm);
4661 }
4662 }
4663
4664 if(get_bit(quest_rules,qr_MORESOUNDS))
4665 {
4666 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4667 {
4668 if (combobuf[cid].usrflags&cflag3)
4669 {
4670 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4671 }
4672 }
4673 else
4674 {
4675 if (combobuf[cid].usrflags&cflag3)
4676 {
4677 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4678 }
4679 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4680 }
4681 }
4682
4683 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4684 if(decotype > 3) decotype = 0;
4685 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4686 switch(decotype)
4687 {
4688 case -2: break; //nothing
4689 case -1:
4690 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4691 break;
4692 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4693 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4694 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4695 }
4696 }
4697 9918222 }
4698
4699 9918222 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4700 {
4701 /*
4702 int32_t par_item = w->parentitem;
4703 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4704 int32_t usewpn = -1;
4705 if ( par_item > -1 )
4706 {
4707 usewpn = itemsbuf[par_item].useweapon;
4708 }
4709 else if ( par_item == -1 && w->ScriptGenerated )
4710 {
4711 usewpn = w->useweapon;
4712 }
4713 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4714 */
4715
4716 9918222 byte dontignore = 0;
4717 9918222 byte dontignoreffc = 0;
4718
4719
4720
4721
4722
4723 //keep things inside the screen boundaries
4724 9918222 bx=vbound(bx, 0, 255);
4725 9918222 by=vbound(by, 0, 176);
4726 9918222 int32_t fx=vbound(bx, 0, 255);
4727 9918222 int32_t fy=vbound(by, 0, 176);
4728 9918222 int32_t cid = MAPCOMBO(bx,by);
4729
4730 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4731
3/4
✓ Branch 0 taken 9918222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 9917758 times.
9918222 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 464 times.
464 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4733
4734 //first things first
4735
2/4
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 464 times.
464 if(z>8||fakez>8) return;
4736
4737 //find out which combo row/column the coordinates are in
4738 464 bx &= 0xF0;
4739 464 by &= 0xF0;
4740
4741 464 int32_t flag = MAPFLAG(bx,by);
4742 464 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4743 464 int32_t flag3=0;
4744 464 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4745 464 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4746 464 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4747 464 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4748
4749
4/8
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 464 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 464 times.
464 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4750 flag3=mfWAND;
4751
4752
4/8
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 464 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 464 times.
464 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4753 flag3=mfSTRIKE;
4754
4755 464 int32_t i = (bx>>4) + by;
4756
4757
6/12
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 464 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 464 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 464 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 464 times.
464 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4758 464 return;
4759
4760 if(i > 175)
4761 return;
4762
4763 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4764
4765 //findentrance(bx,by,mfWAND,true);
4766 //findentrance(bx,by,mfSTRIKE,true);
4767 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4768 {
4769 if(flag3==mfWAND||flag3==mfSTRIKE)
4770 {
4771 findentrance(fx,fy,mfWAND,true);
4772 findentrance(fx,fy,mfSTRIKE,true);
4773 }
4774 }
4775
4776 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4777
4778 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4779 9918222 }
4780
4781 9918222 void HeroClass::check_pound_block2(int32_t bx, int32_t by, weapon *w)
4782 {
4783 /*
4784 int32_t par_item = w->parentitem;
4785 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
4786 int32_t usewpn = -1;
4787 if ( par_item > -1 )
4788 {
4789 usewpn = itemsbuf[par_item].useweapon;
4790 }
4791 else if ( par_item == -1 && w->ScriptGenerated )
4792 {
4793 usewpn = w->useweapon;
4794 }
4795 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
4796 */
4797 //keep things inside the screen boundaries
4798 9918222 bx=vbound(bx, 0, 255);
4799 9918222 by=vbound(by, 0, 176);
4800 9918222 int32_t fx=vbound(bx, 0, 255);
4801 9918222 int32_t fy=vbound(by, 0, 176);
4802 9918222 int32_t cid = MAPCOMBO(bx,by);
4803 9918222 byte dontignore = MatchComboTrigger (w, combobuf, cid);
4804
3/4
✓ Branch 0 taken 9918222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 9917758 times.
9918222 if(w->useweapon != wHammer && !dontignore ) return;
4805
4806
4807
4808
4809 //first things first
4810
2/4
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 464 times.
464 if(z>8||fakez>8) return;
4811
4812 //find out which combo row/column the coordinates are in
4813 464 bx &= 0xF0;
4814 464 by &= 0xF0;
4815
4816 464 int32_t type = COMBOTYPE(bx,by);
4817 464 int32_t type2 = FFCOMBOTYPE(fx,fy);
4818 464 int32_t flag = MAPFLAG(bx,by);
4819 464 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4820 464 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4821 464 int32_t i = (bx>>4) + by;
4822
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 319 times.
464 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4823
4824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
319 if(i > 175)
4825 return;
4826
4827 319 bool ignorescreen=false;
4828 319 bool ignoreffc=false;
4829 319 bool pound=false;
4830
4831
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4832 type = cNONE;
4833
5/10
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 319 times.
319 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
4834 319 ignorescreen = true; // Affect only FFCs
4835
4836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
319 if(get_bit(w->wscreengrid, i) != 0)
4837 {
4838 ignorescreen = true; dontignore = 0;
4839 }
4840
4841 319 int32_t current_ffcombo = getFFCAt(fx,fy);
4842
4843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4844 319 ignoreffc = true;
4845 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4846 type2 = cNONE;
4847
3/6
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 319 times.
319 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
4848 319 ignoreffc = true;
4849
4850
2/4
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 319 times.
319 if(ignorescreen && ignoreffc) // Nothing to do.
4851 319 return;
4852
4853 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4854
4855 if(!ignorescreen || dontignore)
4856 {
4857 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
4858 {
4859 findentrance(bx,by,mfHAMMER,true);
4860 findentrance(bx,by,mfSTRIKE,true);
4861 }
4862 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
4863 {
4864 findentrance(bx,by,mfHAMMER,true);
4865 findentrance(bx,by,mfSTRIKE,true);
4866 }
4867 else if((flag >= 16)&&(flag <= 31))
4868 {
4869 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4870 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4871 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4872 }
4873 else if(flag == mfARMOS_SECRET)
4874 {
4875 s->data[i] = s->secretcombo[sSTAIRS];
4876 s->cset[i] = s->secretcset[sSTAIRS];
4877 s->sflag[i] = s->secretflag[sSTAIRS];
4878 sfx(tmpscr->secretsfx);
4879 }
4880 else if((flag2 >= 16)&&(flag2 <= 31))
4881 {
4882 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4883 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4884 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4885 }
4886 else if(flag2 == mfARMOS_SECRET)
4887 {
4888 s->data[i] = s->secretcombo[sSTAIRS];
4889 s->cset[i] = s->secretcset[sSTAIRS];
4890 s->sflag[i] = s->secretflag[sSTAIRS];
4891 sfx(tmpscr->secretsfx);
4892 }
4893 else pound = true;
4894 }
4895
4896 if(!ignoreffc)
4897 {
4898 if(flag3==mfHAMMER||flag3==mfSTRIKE)
4899 {
4900 findentrance(fx,fy,mfHAMMER,true);
4901 findentrance(fx,fy,mfSTRIKE,true);
4902 }
4903 else
4904 {
4905 s->ffcs[current_ffcombo].incData(1);
4906 }
4907 }
4908
4909 if(!ignorescreen || dontignore)
4910 {
4911 if(pound)
4912 s->data[i]+=1;
4913
4914 set_bit(w->wscreengrid,i,1);
4915
4916 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4917 {
4918 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4919 sfx(tmpscr->secretsfx);
4920 }
4921
4922 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4923 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4924
4925 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4926 }
4927
4928 if(!ignoreffc)
4929 {
4930 set_bit(ffcgrid,current_ffcombo,1);
4931
4932 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4933 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4934 }
4935
4936 return;
4937 9918222 }
4938
4939 void HeroClass::check_slash_block(weapon *w)
4940 {
4941 //first things
4942
4943 int32_t par_item = w->parentitem;
4944 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4945 int32_t usewpn = -1;
4946 if ( par_item > -1 )
4947 {
4948 usewpn = itemsbuf[par_item].useweapon;
4949 }
4950 else if ( par_item == -1 && w->ScriptGenerated )
4951 {
4952 usewpn = w->useweapon;
4953 }
4954 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4955 if(usewpn != wSword) return;
4956
4957
4958 int32_t bx = 0, by = 0;
4959 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
4960 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
4961 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4962 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4963 //keep things inside the screen boundaries
4964 bx=vbound(bx, 0, 255);
4965 by=vbound(by, 0, 176);
4966 int32_t fx=vbound(bx, 0, 255);
4967 int32_t fy=vbound(by, 0, 176);
4968
4969 int32_t cid = MAPCOMBO(bx,by);
4970
4971 //find out which combo row/column the coordinates are in
4972 bx &= 0xF0;
4973 by &= 0xF0;
4974
4975 int32_t type = COMBOTYPE(bx,by);
4976 int32_t type2 = FFCOMBOTYPE(fx,fy);
4977 int32_t flag = MAPFLAG(bx,by);
4978 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4979 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4980 int32_t i = (bx>>4) + by;
4981
4982 if(i > 175)
4983 {
4984 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4985 return;
4986 }
4987
4988 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4989 type = cNONE;
4990 bool ignorescreen=false;
4991 bool ignoreffc=false;
4992
4993 if(get_bit(screengrid, i) != 0)
4994 {
4995 ignorescreen = true;
4996 }
4997
4998 int32_t current_ffcombo = getFFCAt(fx,fy);
4999
5000 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5001 {
5002 ignoreffc = true;
5003 }
5004 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
5005 type2 = cNONE;
5006 if(!isCuttableType(type) &&
5007 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5008 {
5009 ignorescreen = true;
5010 }
5011
5012 if(!isCuttableType(type2) &&
5013 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5014 {
5015 ignoreffc = true;
5016 }
5017
5018 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5019
5020 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5021
5022 if(!ignorescreen)
5023 {
5024 if((flag >= 16)&&(flag <= 31))
5025 {
5026 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5027 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5028 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5029 }
5030 else if(flag == mfARMOS_SECRET)
5031 {
5032 s->data[i] = s->secretcombo[sSTAIRS];
5033 s->cset[i] = s->secretcset[sSTAIRS];
5034 s->sflag[i] = s->secretflag[sSTAIRS];
5035 sfx(tmpscr->secretsfx);
5036 }
5037 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5038 {
5039 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5040 {
5041 findentrance(bx,by,mfSWORD+i2,true);
5042 }
5043
5044 findentrance(bx,by,mfSTRIKE,true);
5045 }
5046 else if(((flag2 >= 16)&&(flag2 <= 31)))
5047 {
5048 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5049 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5050 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5051 }
5052 else if(flag2 == mfARMOS_SECRET)
5053 {
5054 s->data[i] = s->secretcombo[sSTAIRS];
5055 s->cset[i] = s->secretcset[sSTAIRS];
5056 s->sflag[i] = s->secretflag[sSTAIRS];
5057 sfx(tmpscr->secretsfx);
5058 }
5059 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5060 {
5061 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5062 {
5063 findentrance(bx,by,mfSWORD+i2,true);
5064 }
5065
5066 findentrance(bx,by,mfSTRIKE,true);
5067 }
5068 else
5069 {
5070 if(isCuttableNextType(type))
5071 {
5072 s->data[i]++;
5073 }
5074 else
5075 {
5076 s->data[i] = s->undercombo;
5077 s->cset[i] = s->undercset;
5078 s->sflag[i] = 0;
5079 }
5080
5081 //pausenow=true;
5082 }
5083 }
5084
5085 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5086 {
5087 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5088 {
5089 findentrance(bx,by,mfSWORD+i2,true);
5090 }
5091
5092 findentrance(fx,fy,mfSTRIKE,true);
5093 }
5094 else if(!ignoreffc)
5095 {
5096 if(isCuttableNextType(type2))
5097 {
5098 s->ffcs[current_ffcombo].incData(1);
5099 }
5100 else
5101 {
5102 s->ffcs[current_ffcombo].setData(s->undercombo);
5103 s->ffcs[current_ffcombo].cset = s->undercset;
5104 }
5105 }
5106
5107 if(!ignorescreen)
5108 {
5109 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5110
5111 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5112 {
5113 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5114 sfx(tmpscr->secretsfx);
5115 }
5116 else if(isCuttableItemType(type))
5117 {
5118 int32_t it = -1;
5119 int32_t thedropset = -1;
5120 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5121 {
5122 if ( combobuf[cid].usrflags&cflag11 )
5123 {
5124 it = combobuf[cid].attribytes[1];
5125 }
5126 else
5127 {
5128 it = select_dropitem(combobuf[cid].attribytes[1]);
5129 thedropset = combobuf[cid].attribytes[1];
5130 }
5131 }
5132 else
5133 {
5134 it = select_dropitem(12);
5135 thedropset = 12;
5136 }
5137
5138 if(it!=-1)
5139 {
5140 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5141 itm->from_dropset = thedropset;
5142 items.add(itm);
5143 }
5144 }
5145
5146 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5147
5148 if(get_bit(quest_rules,qr_MORESOUNDS))
5149 {
5150 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5151 {
5152 if (combobuf[cid].usrflags&cflag3)
5153 {
5154 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5155 }
5156 }
5157 else
5158 {
5159 if (combobuf[cid].usrflags&cflag3)
5160 {
5161 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5162 }
5163 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5164 }
5165 }
5166
5167 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5168 if(decotype > 3) decotype = 0;
5169 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5170 switch(decotype)
5171 {
5172 case -2: break; //nothing
5173 case -1:
5174 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5175 break;
5176 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5177 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5178 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5179 }
5180 }
5181
5182 if(!ignoreffc)
5183 {
5184 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5185
5186 if(isCuttableItemType(type2))
5187 {
5188 int32_t it=-1;
5189 int32_t thedropset = -1;
5190 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5191 {
5192 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5193 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5194 else
5195 {
5196 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5197 it = select_dropitem(thedropset);
5198 }
5199 }
5200 else
5201 {
5202 it = select_dropitem(12);
5203 thedropset = 12;
5204 }
5205
5206 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5207 {
5208 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5209 itm->from_dropset = thedropset;
5210 items.add(itm);
5211 }
5212 }
5213
5214 if(get_bit(quest_rules,qr_MORESOUNDS))
5215 {
5216 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5217 {
5218 if (combobuf[cid].usrflags&cflag3)
5219 {
5220 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5221 }
5222 }
5223 else
5224 {
5225 if (combobuf[cid].usrflags&cflag3)
5226 {
5227 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5228 }
5229 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5230 }
5231 }
5232
5233 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5234 if(decotype > 3) decotype = 0;
5235 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5236 switch(decotype)
5237 {
5238 case -2: break; //nothing
5239 case -1:
5240 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5241 break;
5242 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5243 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5244 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5245 }
5246 }
5247 }
5248
5249 //TODO: Boomerang that cuts bushes. -L
5250 /*void HeroClass::slash_bush()
5251 {
5252
5253 }*/
5254
5255 24382 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5256 {
5257 //keep things inside the screen boundaries
5258 24382 bx=vbound(bx, 0, 255);
5259 24382 by=vbound(by, 0, 176);
5260 24382 int32_t fx=vbound(bx, 0, 255);
5261 24382 int32_t fy=vbound(by, 0, 176);
5262 24382 int32_t cid = MAPCOMBO(bx,by);
5263
5264 //first things first
5265
2/4
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24382 times.
24382 if(z>8||fakez>8) return;
5266
5267 //find out which combo row/column the coordinates are in
5268 24382 bx &= 0xF0;
5269 24382 by &= 0xF0;
5270
5271 24382 int32_t flag = MAPFLAG(bx,by);
5272 24382 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5273 24382 int32_t flag3=0;
5274 24382 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5275 24382 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5276 24382 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5277 24382 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5278
5279
4/8
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24382 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24382 times.
24382 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5280 flag3=mfWAND;
5281
5282
4/8
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24382 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24382 times.
24382 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5283 flag3=mfSTRIKE;
5284
5285 24382 int32_t i = (bx>>4) + by;
5286
5287
6/12
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24382 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24382 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24382 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 24382 times.
✗ Branch 11 not taken.
24382 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5288 24382 return;
5289
5290 if(i > 175)
5291 return;
5292
5293 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5294
5295 //findentrance(bx,by,mfWAND,true);
5296 //findentrance(bx,by,mfSTRIKE,true);
5297 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5298 {
5299 if(flag3==mfWAND||flag3==mfSTRIKE)
5300 {
5301 findentrance(fx,fy,mfWAND,true);
5302 findentrance(fx,fy,mfSTRIKE,true);
5303 }
5304 }
5305
5306 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5307 24382 }
5308
5309 184 void HeroClass::check_pound_block(int32_t bx, int32_t by)
5310 {
5311 //keep things inside the screen boundaries
5312 184 bx=vbound(bx, 0, 255);
5313 184 by=vbound(by, 0, 176);
5314 184 int32_t fx=vbound(bx, 0, 255);
5315 184 int32_t fy=vbound(by, 0, 176);
5316 184 int32_t cid = MAPCOMBO(bx,by);
5317
5318 //first things first
5319
2/4
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 184 times.
184 if(z>8||fakez>8) return;
5320
5321 //find out which combo row/column the coordinates are in
5322 184 bx &= 0xF0;
5323 184 by &= 0xF0;
5324
5325 184 int32_t type = COMBOTYPE(bx,by);
5326 184 int32_t type2 = FFCOMBOTYPE(fx,fy);
5327 184 int32_t flag = MAPFLAG(bx,by);
5328 184 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5329 184 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5330 184 int32_t i = (bx>>4) + by;
5331
5332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 184 times.
184 if(i > 175)
5333 return;
5334
5335 184 bool ignorescreen=false;
5336 184 bool ignoreffc=false;
5337 184 bool pound=false;
5338
5339
6/10
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 156 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 156 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 156 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 156 times.
184 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5340 156 ignorescreen = true; // Affect only FFCs
5341
5342
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 13 times.
184 if(get_bit(screengrid, i) != 0)
5343 13 ignorescreen = true;
5344
5345 184 int32_t current_ffcombo = getFFCAt(fx,fy);
5346
5347
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 183 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
184 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5348 183 ignoreffc = true;
5349
5350
3/6
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 184 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 184 times.
184 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5351 184 ignoreffc = true;
5352
5353
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 164 times.
184 if(ignorescreen && ignoreffc) // Nothing to do.
5354 164 return;
5355
5356 20 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5357
5358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!ignorescreen)
5359 {
5360
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5361 {
5362 findentrance(bx,by,mfHAMMER,true);
5363 findentrance(bx,by,mfSTRIKE,true);
5364 }
5365
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5366 {
5367 findentrance(bx,by,mfHAMMER,true);
5368 findentrance(bx,by,mfSTRIKE,true);
5369 }
5370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 else if((flag >= 16)&&(flag <= 31))
5371 {
5372 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5373 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5374 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5375 }
5376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 else if(flag == mfARMOS_SECRET)
5377 {
5378 s->data[i] = s->secretcombo[sSTAIRS];
5379 s->cset[i] = s->secretcset[sSTAIRS];
5380 s->sflag[i] = s->secretflag[sSTAIRS];
5381 sfx(tmpscr->secretsfx);
5382 }
5383
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 else if((flag2 >= 16)&&(flag2 <= 31))
5384 {
5385 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5386 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5387 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5388 }
5389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 else if(flag2 == mfARMOS_SECRET)
5390 {
5391 s->data[i] = s->secretcombo[sSTAIRS];
5392 s->cset[i] = s->secretcset[sSTAIRS];
5393 s->sflag[i] = s->secretflag[sSTAIRS];
5394 sfx(tmpscr->secretsfx);
5395 }
5396 20 else pound = true;
5397 20 }
5398
5399
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!ignoreffc)
5400 {
5401 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5402 {
5403 findentrance(fx,fy,mfHAMMER,true);
5404 findentrance(fx,fy,mfSTRIKE,true);
5405 }
5406 else
5407 {
5408 s->ffcs[current_ffcombo].incData(1);
5409 }
5410 }
5411
5412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!ignorescreen)
5413 {
5414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(pound)
5415 20 s->data[i]+=1;
5416
5417 20 set_bit(screengrid,i,1);
5418
5419
2/8
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5420 {
5421 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5422 sfx(tmpscr->secretsfx);
5423 }
5424
5425
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5426 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5427
5428 20 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5429 20 }
5430
5431
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!ignoreffc)
5432 {
5433 set_bit(ffcgrid,current_ffcombo,1);
5434
5435 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5436 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5437 }
5438
5439 20 return;
5440 184 }
5441
5442
5443 void HeroClass::check_wand_block(weapon *w)
5444 {
5445
5446 int32_t par_item = w->parentitem;
5447 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5448 int32_t usewpn = -1;
5449 if ( par_item > -1 )
5450 {
5451 usewpn = itemsbuf[par_item].useweapon;
5452 }
5453 else if ( par_item == -1 && w->ScriptGenerated )
5454 {
5455 usewpn = w->useweapon;
5456 }
5457 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5458 if(usewpn != wWand) return;
5459
5460
5461 int32_t bx = 0, by = 0;
5462 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5463 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5464
5465 //keep things inside the screen boundaries
5466 bx=vbound(bx, 0, 255);
5467 by=vbound(by, 0, 176);
5468 int32_t fx=vbound(bx, 0, 255);
5469 int32_t fy=vbound(by, 0, 176);
5470 int32_t cid = MAPCOMBO(bx,by);
5471 //first things first
5472 if(z>8||fakez>8) return;
5473
5474 //find out which combo row/column the coordinates are in
5475 bx &= 0xF0;
5476 by &= 0xF0;
5477
5478 int32_t flag = MAPFLAG(bx,by);
5479 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5480 int32_t flag3=0;
5481 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5482 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5483 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5484 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5485
5486 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5487 flag3=mfWAND;
5488
5489 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5490 flag3=mfSTRIKE;
5491
5492 int32_t i = (bx>>4) + by;
5493
5494 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5495 return;
5496
5497 if(i > 175)
5498 return;
5499
5500 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5501
5502 //findentrance(bx,by,mfWAND,true);
5503 //findentrance(bx,by,mfSTRIKE,true);
5504 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5505 {
5506 if(flag3==mfWAND||flag3==mfSTRIKE)
5507 {
5508 findentrance(fx,fy,mfWAND,true);
5509 findentrance(fx,fy,mfSTRIKE,true);
5510 }
5511 }
5512
5513 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5514 }
5515
5516 void HeroClass::check_pound_block(weapon *w)
5517 {
5518
5519 int32_t par_item = w->parentitem;
5520 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
5521 int32_t usewpn = -1;
5522 if ( par_item > -1 )
5523 {
5524 usewpn = itemsbuf[par_item].useweapon;
5525 }
5526 else if ( par_item == -1 && w->ScriptGenerated )
5527 {
5528 usewpn = w->useweapon;
5529 }
5530 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
5531 if(usewpn != wHammer) return;
5532
5533
5534 int32_t bx = 0, by = 0;
5535 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5536 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5537 //keep things inside the screen boundaries
5538 bx=vbound(bx, 0, 255);
5539 by=vbound(by, 0, 176);
5540 int32_t fx=vbound(bx, 0, 255);
5541 int32_t fy=vbound(by, 0, 176);
5542 int32_t cid = MAPCOMBO(bx,by);
5543 //first things first
5544 if(z>8||fakez>8) return;
5545
5546 //find out which combo row/column the coordinates are in
5547 bx &= 0xF0;
5548 by &= 0xF0;
5549
5550 int32_t type = COMBOTYPE(bx,by);
5551 int32_t type2 = FFCOMBOTYPE(fx,fy);
5552 int32_t flag = MAPFLAG(bx,by);
5553 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5554 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5555 int32_t i = (bx>>4) + by;
5556
5557 if(i > 175)
5558 return;
5559
5560 bool ignorescreen=false;
5561 bool ignoreffc=false;
5562 bool pound=false;
5563
5564 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5565 ignorescreen = true; // Affect only FFCs
5566
5567 if(get_bit(screengrid, i) != 0)
5568 ignorescreen = true;
5569
5570 int32_t current_ffcombo = getFFCAt(fx,fy);
5571
5572 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5573 ignoreffc = true;
5574
5575 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5576 ignoreffc = true;
5577
5578 if(ignorescreen && ignoreffc) // Nothing to do.
5579 return;
5580
5581 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5582
5583 if(!ignorescreen)
5584 {
5585 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5586 {
5587 findentrance(bx,by,mfHAMMER,true);
5588 findentrance(bx,by,mfSTRIKE,true);
5589 }
5590 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5591 {
5592 findentrance(bx,by,mfHAMMER,true);
5593 findentrance(bx,by,mfSTRIKE,true);
5594 }
5595 else if((flag >= 16)&&(flag <= 31))
5596 {
5597 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5598 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5599 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5600 }
5601 else if(flag == mfARMOS_SECRET)
5602 {
5603 s->data[i] = s->secretcombo[sSTAIRS];
5604 s->cset[i] = s->secretcset[sSTAIRS];
5605 s->sflag[i] = s->secretflag[sSTAIRS];
5606 sfx(tmpscr->secretsfx);
5607 }
5608 else if((flag2 >= 16)&&(flag2 <= 31))
5609 {
5610 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5611 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5612 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5613 }
5614 else if(flag2 == mfARMOS_SECRET)
5615 {
5616 s->data[i] = s->secretcombo[sSTAIRS];
5617 s->cset[i] = s->secretcset[sSTAIRS];
5618 s->sflag[i] = s->secretflag[sSTAIRS];
5619 sfx(tmpscr->secretsfx);
5620 }
5621 else pound = true;
5622 }
5623
5624 if(!ignoreffc)
5625 {
5626 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5627 {
5628 findentrance(fx,fy,mfHAMMER,true);
5629 findentrance(fx,fy,mfSTRIKE,true);
5630 }
5631 else
5632 {
5633 s->ffcs[current_ffcombo].incData(1);
5634 }
5635 }
5636
5637 if(!ignorescreen)
5638 {
5639 if(pound)
5640 s->data[i]+=1;
5641
5642 set_bit(screengrid,i,1);
5643
5644 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5645 {
5646 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5647 sfx(tmpscr->secretsfx);
5648 }
5649
5650 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5651 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5652
5653 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5654 }
5655
5656 if(!ignoreffc)
5657 {
5658 set_bit(ffcgrid,current_ffcombo,1);
5659
5660 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5661 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5662 }
5663
5664 return;
5665 }
5666
5667 //defend results should match defence types.
5668 //RETURN VALUES:
5669 // -1 iGNORE WEAPON
5670 // 0 No effects
5671 // 1 Effects, weapon is not ignored or removed
5672 4421 int32_t HeroClass::defend(weapon *w)
5673 {
5674 4421 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5675
1/25
✓ Branch 0 taken 4421 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
4421 switch(def)
5676 {
5677 4421 case edNORMAL: return 1;
5678 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5679 {
5680 w->power *= 0.5;
5681 return 1;
5682 }
5683 case edQUARTDAMAGE:
5684 {
5685 w->power *= 0.25;
5686 return 1;
5687 }
5688 case edSTUNONLY:
5689 {
5690 setStunClock(120);
5691 return 1;
5692 }
5693 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5694 {
5695 if (w->power > 0)
5696 {
5697 setStunClock(120);
5698 return 1;
5699 }
5700 else
5701 {
5702 sfx(WAV_CHINK,pan(int32_t(x)));
5703 w->dead = 0;
5704 return -1;
5705 }
5706 }
5707 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5708 {
5709 if (w->power > 0)
5710 {
5711 setStunClock(120);
5712 return 1;
5713 }
5714 else
5715 {
5716 return -1;
5717 }
5718 }
5719 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5720 {
5721 if (w->power < 1)
5722 {
5723 sfx(WAV_CHINK,pan(int32_t(x)));
5724 w->dead = 0;
5725 return -1;
5726 }
5727 else
5728 {
5729 return 1;
5730 }
5731 }
5732 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5733 {
5734 if (w->power < 2)
5735 {
5736 sfx(WAV_CHINK,pan(int32_t(x)));
5737 w->dead = 0;
5738 return -1;
5739 }
5740 else
5741 {
5742 return 1;
5743 }
5744 }
5745 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5746 {
5747 if (w->power < 4)
5748 {
5749 sfx(WAV_CHINK,pan(int32_t(x)));
5750 w->dead = 0;
5751 return -1;
5752 }
5753 else
5754 {
5755 return 1;
5756 }
5757 }
5758 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5759 {
5760 if (w->power < 6)
5761 {
5762 sfx(WAV_CHINK,pan(int32_t(x)));
5763 w->dead = 0;
5764 return -1;
5765 }
5766 else
5767 {
5768 return 1;
5769 }
5770 }
5771 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5772 {
5773 if (w->power < 8)
5774 {
5775 sfx(WAV_CHINK,pan(int32_t(x)));
5776 w->dead = 0;
5777 return -1;
5778 }
5779 else
5780 {
5781 return 1;
5782 }
5783 }
5784 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5785 {
5786 sfx(WAV_CHINK,pan(int32_t(x)));
5787 w->dead = 0;
5788 return -1;
5789 }
5790 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5791 {
5792 if (w->power < 1)
5793 {
5794 return -1;
5795 }
5796 else return 1;
5797 }
5798 case edIGNORE: // : IMPLEMENTED : Do Nothing
5799 {
5800 return -1;
5801 }
5802 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5803 {
5804 game->set_life(0);
5805 return 1;
5806 }
5807 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5808 {
5809 if (w->power < 10)
5810 {
5811 sfx(WAV_CHINK,pan(int32_t(x)));
5812 w->dead = 0;
5813 return -1;
5814 }
5815 else
5816 {
5817 return 1;
5818 }
5819 }
5820 case ed2x: // : IMPLEMENTED : Double damage.
5821 {
5822 w->power *= 2;
5823 return 1;
5824 }
5825 case ed3x: // : IMPLEMENTED : Triple Damage.
5826 {
5827 w->power *= 3;
5828 return 1;
5829 }
5830 case ed4x: // : IMPLEMENTED : 4x damage.
5831 {
5832 w->power *= 4;
5833 return 1;
5834 }
5835 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5836 {
5837 //sfx(WAV_HEAL,pan(int32_t(x)));
5838 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5839 w->dead = 0;
5840 return -1;
5841 }
5842
5843 case edFREEZE: return 1; //Not IMPLEMENTED
5844
5845 case edLEVELDAMAGE: //Damage * item level
5846 {
5847 w->power *= w->family_level;
5848 return 1;
5849 }
5850 case edLEVELREDUCTION: //Damage / item level
5851 {
5852 if ( w->family_level > 0 )
5853 {
5854 w->power /= w->family_level;
5855 }
5856 else w->power = 0;
5857 return 1;
5858 }
5859
5860 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5861 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5862 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5863 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5864
5865 //edSHOCK, //buzz blob
5866
5867
5868 case edBREAKSHIELD: //destroy the player's present shield
5869 {
5870 w->power = 0;
5871 w->dead = 0;
5872 int32_t itemid = getCurrentShield();
5873 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5874 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5875 game->set_item(itemid, false);
5876 //Remove Hero's shield
5877 return -1;
5878 }
5879
5880
5881
5882 default: return 0;
5883 }
5884 4421 }
5885
5886 4240 int32_t HeroClass::compareDir(int32_t other)
5887 {
5888
5/6
✓ Branch 0 taken 4235 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4235 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 4238 times.
4240 if(other != NORMAL_DIR(other))
5889 2 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5890 4238 int32_t ret = 0;
5891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4238 times.
4238 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5892
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
✓ Branch 2 taken 714 times.
✓ Branch 3 taken 1393 times.
✓ Branch 4 taken 1333 times.
4238 switch(d)
5893 {
5894 case up:
5895 {
5896
3/3
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 311 times.
798 switch(X_DIR(other))
5897 {
5898 case left:
5899 318 ret |= CMPDIR_RIGHT;
5900 318 break;
5901 case right:
5902 311 ret |= CMPDIR_LEFT;
5903 311 break;
5904 }
5905
3/3
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 537 times.
798 switch(Y_DIR(other))
5906 {
5907 case up:
5908 174 ret |= CMPDIR_BACK;
5909 174 break;
5910 case down:
5911 537 ret |= CMPDIR_FRONT;
5912 537 break;
5913 }
5914 798 break;
5915 }
5916 case down:
5917 {
5918
3/3
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 298 times.
714 switch(X_DIR(other))
5919 {
5920 case left:
5921 233 ret |= CMPDIR_LEFT;
5922 233 break;
5923 case right:
5924 298 ret |= CMPDIR_RIGHT;
5925 298 break;
5926 }
5927
3/3
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 494 times.
✓ Branch 2 taken 134 times.
714 switch(Y_DIR(other))
5928 {
5929 case up:
5930 494 ret |= CMPDIR_FRONT;
5931 494 break;
5932 case down:
5933 134 ret |= CMPDIR_BACK;
5934 134 break;
5935 }
5936 714 break;
5937 }
5938 case left:
5939 {
5940
3/3
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 1125 times.
1393 switch(X_DIR(other))
5941 {
5942 case left:
5943 212 ret |= CMPDIR_BACK;
5944 212 break;
5945 case right:
5946 1125 ret |= CMPDIR_FRONT;
5947 1125 break;
5948 }
5949
3/3
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 446 times.
✓ Branch 2 taken 455 times.
1393 switch(Y_DIR(other))
5950 {
5951 case up:
5952 446 ret |= CMPDIR_LEFT;
5953 446 break;
5954 case down:
5955 455 ret |= CMPDIR_RIGHT;
5956 455 break;
5957 }
5958 1393 break;
5959 }
5960 case right:
5961 {
5962
3/3
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1086 times.
✓ Branch 2 taken 193 times.
1333 switch(X_DIR(other))
5963 {
5964 case left:
5965 1086 ret |= CMPDIR_FRONT;
5966 1086 break;
5967 case right:
5968 193 ret |= CMPDIR_BACK;
5969 193 break;
5970 }
5971
3/3
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 513 times.
1333 switch(Y_DIR(other))
5972 {
5973 case up:
5974 364 ret |= CMPDIR_RIGHT;
5975 364 break;
5976 case down:
5977 513 ret |= CMPDIR_LEFT;
5978 513 break;
5979 }
5980 1333 break;
5981 }
5982 }
5983 4238 return ret;
5984 4240 }
5985
5986 4240 bool compareShield(int32_t cmpdir, itemdata const& shield)
5987 {
5988
1/2
✓ Branch 0 taken 4240 times.
✗ Branch 1 not taken.
4240 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5989
1/2
✓ Branch 0 taken 4240 times.
✗ Branch 1 not taken.
4240 if(standard) //Use standard sides, either a passive shield, or a held active shield
5990 {
5991
3/4
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3242 times.
4240 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5992 3242 return true;
5993
3/4
✓ Branch 0 taken 713 times.
✓ Branch 1 taken 285 times.
✓ Branch 2 taken 713 times.
✗ Branch 3 not taken.
998 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
5994 return true;
5995
3/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 567 times.
✓ Branch 2 taken 431 times.
✗ Branch 3 not taken.
998 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
5996 return true;
5997
3/4
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 445 times.
998 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
5998 return true;
5999 998 }
6000 else //Active Shield that is NOT held down
6001 {
6002 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
6003 return true;
6004 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
6005 return true;
6006 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
6007 return true;
6008 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
6009 return true;
6010 }
6011 998 return false;
6012 4240 }
6013
6014 3222464 int32_t HeroClass::EwpnHit()
6015 {
6016
2/2
✓ Branch 0 taken 3220408 times.
✓ Branch 1 taken 3308801 times.
6529209 for(int32_t i=0; i<Ewpns.Count(); i++)
6017 {
6018
2/2
✓ Branch 0 taken 3304380 times.
✓ Branch 1 taken 4421 times.
3308801 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6019 {
6020 4421 weapon *ew = (weapon*)(Ewpns.spr(i));
6021
6022
3/6
✓ Branch 0 taken 4421 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4421 times.
4421 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6023 break;
6024
6025 4421 int32_t stompid = current_item_id(itype_stompboots);
6026
6027
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4421 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6028 ((z+fakez) > (ew->z+(ew->fakez))) ||
6029 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6030 {
6031 itemdata const& stomp = itemsbuf[stompid];
6032 bool remove = false;
6033 switch(ew->id)
6034 {
6035 case ewFireball2:
6036 case ewFireball:
6037 if(ew->type & 1) //Boss fireball
6038 {
6039 if(stomp.misc2 & (shFIREBALL2))
6040 remove = true;
6041 }
6042 else
6043 {
6044 if(stomp.misc2 & (shFIREBALL))
6045 remove = true;
6046 }
6047
6048 break;
6049
6050 case ewMagic:
6051 if((stomp.misc2 & shMAGIC))
6052 remove = true;
6053 break;
6054
6055 case ewSword:
6056 if((stomp.misc2 & shSWORD))
6057 remove = true;
6058
6059 break;
6060
6061 case ewFlame:
6062 if((stomp.misc2 & shFLAME))
6063 remove = true;
6064
6065 break;
6066
6067 case ewRock:
6068 if((stomp.misc2 & shROCK))
6069 remove = true;
6070
6071 break;
6072
6073 case ewArrow:
6074 if((stomp.misc2 & shARROW))
6075 remove = true;
6076
6077 break;
6078
6079 case ewBrang:
6080 if((stomp.misc2 & shBRANG))
6081 remove = true;
6082
6083 break;
6084
6085 default: // Just throw the script weapons in here...
6086 if(ew->id>=wScript1 && ew->id<=wScript10)
6087 {
6088 if((stomp.misc2 & shSCRIPT))
6089 remove = true;
6090 }
6091
6092 break;
6093 }
6094 if (remove)
6095 {
6096 ew->onhit(false);
6097 sfx(WAV_CHINK,pan(x.getInt()));
6098 continue;
6099 }
6100 }
6101
6102 4421 int32_t defresult = defend(ew);
6103
1/2
✓ Branch 0 taken 4421 times.
✗ Branch 1 not taken.
4421 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6104
6105
2/2
✓ Branch 0 taken 4420 times.
✓ Branch 1 taken 1 times.
4421 if(ew->id==ewWind)
6106 {
6107 1 xofs=1000;
6108 1 action=freeze; FFCore.setHeroAction(freeze);
6109 1 ew->misc=999; // in enemy wind
6110 1 attackclk=0;
6111 1 return -1;
6112 }
6113
6114
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4410 times.
4420 switch(ew->id)
6115 {
6116 case ewLitBomb:
6117 case ewBomb:
6118 case ewLitSBomb:
6119 case ewSBomb:
6120 10 return i;
6121 }
6122
6123 4410 int32_t itemid = getCurrentShield(false);
6124
4/6
✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 4240 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4240 times.
4410 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6125 4240 itemdata const& shield = itemsbuf[itemid];
6126 4240 auto cmpdir = compareDir(ew->dir);
6127 4240 bool hitshield = compareShield(cmpdir, shield);
6128
6129
6130
12/18
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 998 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 644 times.
✓ Branch 4 taken 2598 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2591 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 2591 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2591 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2591 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2591 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2591 times.
4240 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF)
6131 {
6132 1649 return i;
6133 }
6134
6135 2591 paymagiccost(itemid);
6136
6137 2591 bool reflect = false;
6138
6139
7/8
✓ Branch 0 taken 1599 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 199 times.
✓ Branch 4 taken 79 times.
✓ Branch 5 taken 140 times.
✓ Branch 6 taken 112 times.
✓ Branch 7 taken 119 times.
2591 switch(ew->id)
6140 {
6141 case ewFireball2:
6142 case ewFireball:
6143
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1484 times.
1599 if(ew->type & 1) //Boss fireball
6144 {
6145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!(shield.misc1 & (shFIREBALL2)))
6146 115 return i;
6147
6148 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6149 }
6150 else
6151 {
6152
2/2
✓ Branch 0 taken 1435 times.
✓ Branch 1 taken 49 times.
1484 if(!(shield.misc1 & (shFIREBALL)))
6153 49 return i;
6154
6155 1435 reflect = ((shield.misc2 & shFIREBALL) != 0);
6156 }
6157
6158 1435 break;
6159
6160 case ewMagic:
6161
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 8 times.
343 if(!(shield.misc1 & shMAGIC))
6162 8 return i;
6163
6164 335 reflect = ((shield.misc2 & shMAGIC) != 0);
6165 335 break;
6166
6167 case ewSword:
6168
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 8 times.
199 if(!(shield.misc1 & shSWORD))
6169 8 return i;
6170
6171 191 reflect = ((shield.misc2 & shSWORD) != 0);
6172 191 break;
6173
6174 case ewFlame:
6175
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 46 times.
79 if(!(shield.misc1 & shFLAME))
6176 46 return i;
6177
6178 33 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6179 33 break;
6180
6181 case ewRock:
6182
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!(shield.misc1 & shROCK))
6183 return i;
6184
6185 140 reflect = (shield.misc2 & shROCK);
6186 140 break;
6187
6188 case ewArrow:
6189
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!(shield.misc1 & shARROW))
6190 return i;
6191
6192 112 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6193 112 break;
6194
6195 case ewBrang:
6196
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!(shield.misc1 & shBRANG))
6197 return i;
6198
6199 119 break;
6200
6201 default: // Just throw the script weapons in here...
6202 if(ew->id>=wScript1 && ew->id<=wScript10)
6203 {
6204 if(!(shield.misc1 & shSCRIPT))
6205 return i;
6206
6207 reflect = ((shield.misc2 & shSCRIPT) != 0);
6208 }
6209
6210 break;
6211 }
6212
6213
3/4
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 1881 times.
✓ Branch 2 taken 484 times.
✗ Branch 3 not taken.
2365 if(reflect && (ew->unblockable&WPNUNB_REFL))
6214 reflect = false;
6215
3/4
✓ Branch 0 taken 1881 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 1881 times.
✗ Branch 3 not taken.
2365 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6216 return i;
6217
6218 2365 int32_t oldid = ew->id;
6219 2365 ew->onhit(false, reflect ? 2 : 1, dir);
6220
6221
2/2
✓ Branch 0 taken 1881 times.
✓ Branch 1 taken 484 times.
2365 if(ew->id != oldid) // changed type from ewX to wX
6222 {
6223 // ew->power*=game->get_hero_dmgmult();
6224 484 Lwpns.add(ew);
6225 484 Ewpns.remove(ew);
6226 484 ew->isLWeapon = true; //Make sure this gets set everywhere!
6227 484 }
6228
6229
2/2
✓ Branch 0 taken 2177 times.
✓ Branch 1 taken 188 times.
2365 if(ew->id==wRefMagic)
6230 {
6231 188 ew->ignoreHero=true;
6232 188 ew->ignorecombo=-1;
6233 188 }
6234
6235 2365 sfx(shield.usesound,pan(x.getInt()));
6236 2365 }
6237 3306745 }
6238
6239 3220408 return -1;
6240 3222464 }
6241
6242 3222464 int32_t HeroClass::LwpnHit() //only here to check magic hits
6243 {
6244
2/2
✓ Branch 0 taken 3143542 times.
✓ Branch 1 taken 1722788 times.
4866330 for(int32_t i=0; i<Lwpns.Count(); i++)
6245
2/2
✓ Branch 0 taken 1643866 times.
✓ Branch 1 taken 78922 times.
1722788 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6246 {
6247 78922 weapon *lw = (weapon*)(Lwpns.spr(i));
6248
6249
2/2
✓ Branch 0 taken 77502 times.
✓ Branch 1 taken 1420 times.
78922 if((lw->ignoreHero)==true)
6250 1420 break;
6251
6252
4/8
✓ Branch 0 taken 77502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77502 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77502 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 77502 times.
77502 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6253 int32_t itemid = getCurrentShield(false);
6254 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6255 itemdata const& shield = itemsbuf[itemid];
6256 auto cmpdir = compareDir(lw->dir);
6257 bool hitshield = compareShield(cmpdir, shield);
6258 bool reflect = false;
6259
6260 switch(lw->id)
6261 {
6262 case wRefFireball:
6263 if(itemid<0)
6264 return i;
6265
6266 if(lw->type & 1) //Boss fireball
6267 return i;
6268
6269 if(!(shield.misc1 & (shFIREBALL)))
6270 return i;
6271
6272 reflect = ((shield.misc2 & shFIREBALL) != 0);
6273 break;
6274
6275 case wRefMagic:
6276 if(itemid<0)
6277 return i;
6278
6279 if(!(shield.misc1 & shMAGIC))
6280 return i;
6281
6282 reflect = ((shield.misc2 & shMAGIC) != 0);
6283 break;
6284
6285 case wRefBeam:
6286 if(itemid<0)
6287 return i;
6288
6289 if(!(shield.misc1 & shSWORD))
6290 return i;
6291
6292 reflect = ((shield.misc2 & shSWORD) != 0);
6293 break;
6294
6295 case wRefRock:
6296 if(itemid<0)
6297 return i;
6298
6299 if(!(shield.misc1 & shROCK))
6300 return i;
6301
6302 reflect = (shield.misc2 & shROCK);
6303 break;
6304
6305 default:
6306 return -1;
6307 }
6308
6309 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || hopclk==0xFF)
6310 return i;
6311
6312 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6313
6314 paymagiccost(itemid);
6315
6316 lw->onhit(false, 1+reflect, dir);
6317 lw->ignoreHero=true;
6318 lw->ignorecombo=-1;
6319 sfx(shield.usesound,pan(x.getInt()));
6320 }
6321
6322 3144962 return -1;
6323 3222464 }
6324
6325 6230443 void HeroClass::checkhit()
6326 {
6327
2/2
✓ Branch 0 taken 2601478 times.
✓ Branch 1 taken 3628965 times.
6230443 if(checkhero==true)
6328 {
6329
2/2
✓ Branch 0 taken 219113 times.
✓ Branch 1 taken 3409852 times.
3628965 if(hclk>0)
6330 {
6331 219113 --hclk;
6332 219113 }
6333
6334
1/2
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
3628965 if(NayrusLoveShieldClk>0)
6335 {
6336 --NayrusLoveShieldClk;
6337
6338 if(NayrusLoveShieldClk == 0 && nayruitem != -1)
6339 {
6340 stop_sfx(itemsbuf[nayruitem].usesound);
6341 stop_sfx(itemsbuf[nayruitem].usesound+1);
6342 nayruitem = -1;
6343 }
6344 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(NayrusLoveShieldClk&0xF00) && nayruitem != -1)
6345 {
6346 stop_sfx(itemsbuf[nayruitem].usesound);
6347 cont_sfx(itemsbuf[nayruitem].usesound+1);
6348 }
6349 }
6350 3628965 }
6351
6352
4/4
✓ Branch 0 taken 3587420 times.
✓ Branch 1 taken 2643023 times.
✓ Branch 2 taken 3584906 times.
✓ Branch 3 taken 2514 times.
6230443 if(hclk<39 && action==gothit)
6353 {
6354 2514 action=none; FFCore.setHeroAction(none);
6355 2514 }
6356
6357
5/6
✓ Branch 0 taken 3587420 times.
✓ Branch 1 taken 2643023 times.
✓ Branch 2 taken 3587402 times.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3587402 times.
6230443 if(hclk<39 && (action==swimhit || action == sideswimhit))
6358 {
6359 18 SetSwim();
6360 18 }
6361
6362
4/4
✓ Branch 0 taken 36944 times.
✓ Branch 1 taken 6193499 times.
✓ Branch 2 taken 10178 times.
✓ Branch 3 taken 26766 times.
6230443 if(hclk>=40 && action==gothit)
6363 {
6364 26766 int val = check_pitslide();
6365
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 26547 times.
✓ Branch 2 taken 26846 times.
✓ Branch 3 taken 26627 times.
26766 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6366 {
6367
2/2
✓ Branch 0 taken 107384 times.
✓ Branch 1 taken 26846 times.
134230 for(int32_t i=0; i<4; i++)
6368 {
6369
5/5
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 22576 times.
✓ Branch 2 taken 26328 times.
✓ Branch 3 taken 27872 times.
✓ Branch 4 taken 30512 times.
107384 switch(hitdir)
6370 {
6371 case up:
6372
6/6
✓ Branch 0 taken 1387 times.
✓ Branch 1 taken 21189 times.
✓ Branch 2 taken 1696 times.
✓ Branch 3 taken 19493 times.
✓ Branch 4 taken 1395 times.
✓ Branch 5 taken 21181 times.
22576 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6373 {
6374 1395 action=none; FFCore.setHeroAction(none);
6375 1395 }
6376
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21177 times.
21181 else if (val == -1) --y;
6377
6378 22576 break;
6379
6380 case down:
6381
6/6
✓ Branch 0 taken 2144 times.
✓ Branch 1 taken 24184 times.
✓ Branch 2 taken 1835 times.
✓ Branch 3 taken 22349 times.
✓ Branch 4 taken 2160 times.
✓ Branch 5 taken 24168 times.
26328 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6382 {
6383 2160 action=none; FFCore.setHeroAction(none);
6384 2160 }
6385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24168 times.
24168 else if (val == -1) ++y;
6386
6387 26328 break;
6388
6389 case left:
6390
7/8
✓ Branch 0 taken 26978 times.
✓ Branch 1 taken 894 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26978 times.
✓ Branch 4 taken 778 times.
✓ Branch 5 taken 26200 times.
✓ Branch 6 taken 898 times.
✓ Branch 7 taken 26974 times.
27872 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6391 {
6392 898 action=none; FFCore.setHeroAction(none);
6393 898 }
6394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26974 times.
26974 else if (val == -1) --x;
6395
6396 27872 break;
6397
6398 case right:
6399
7/8
✓ Branch 0 taken 29412 times.
✓ Branch 1 taken 1100 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29412 times.
✓ Branch 4 taken 28876 times.
✓ Branch 5 taken 536 times.
✓ Branch 6 taken 1108 times.
✓ Branch 7 taken 29404 times.
30512 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6400 {
6401 1108 action=none; FFCore.setHeroAction(none);
6402 1108 }
6403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29404 times.
29404 else if (val == -1) ++x;
6404
6405 30512 break;
6406 }
6407 107384 }
6408 26846 }
6409 26926 }
6410
6411
17/20
✓ Branch 0 taken 3414358 times.
✓ Branch 1 taken 2816245 times.
✓ Branch 2 taken 3414358 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3411408 times.
✓ Branch 5 taken 2950 times.
✓ Branch 6 taken 3410745 times.
✓ Branch 7 taken 663 times.
✓ Branch 8 taken 3410745 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3410745 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3410597 times.
✓ Branch 13 taken 148 times.
✓ Branch 14 taken 3408712 times.
✓ Branch 15 taken 1885 times.
✓ Branch 16 taken 1851 times.
✓ Branch 17 taken 3406861 times.
✓ Branch 18 taken 3032703 times.
✓ Branch 19 taken 3034554 times.
6230603 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6412 {
6413 5854594 return;
6414 }
6415
6416
2/2
✓ Branch 0 taken 4904953 times.
✓ Branch 1 taken 3406821 times.
8311774 for(int32_t i=0; i<Lwpns.Count(); i++)
6417 {
6418 4904953 sprite *s = Lwpns.spr(i);
6419 4904953 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6420 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6421 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6422
13/14
✓ Branch 0 taken 353122 times.
✓ Branch 1 taken 4551831 times.
✓ Branch 2 taken 1517277 times.
✓ Branch 3 taken 3034554 times.
✓ Branch 4 taken 1517277 times.
✓ Branch 5 taken 1517277 times.
✓ Branch 6 taken 1497606 times.
✓ Branch 7 taken 19671 times.
✓ Branch 8 taken 1497606 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 62500 times.
✓ Branch 11 taken 1435106 times.
✓ Branch 12 taken 39641 times.
✓ Branch 13 taken 22859 times.
4904953 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6423 {
6424
7/10
✓ Branch 0 taken 1410231 times.
✓ Branch 1 taken 47734 times.
✓ Branch 2 taken 47734 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 47716 times.
✓ Branch 8 taken 1457947 times.
✓ Branch 9 taken 18 times.
1457983 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6425
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 (itemid < 0 || itemsbuf[itemid].family!=itype_dinsfire))
6426 {
6427 18 std::vector<int32_t> &ev = FFCore.eventData;
6428 18 ev.clear();
6429 18 ev.push_back(lwpn_dp(i)*10000);
6430 18 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6431 18 ev.push_back(0);
6432 18 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6433 18 ev.push_back(48*10000);
6434 18 ev.push_back(ZSD_LWPN*10000);
6435 18 ev.push_back(s->getUID());
6436
6437 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6438 18 int32_t dmg = ev[0]/10000;
6439 18 bool nullhit = ev[2] != 0;
6440
6441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) {ev.clear(); return;}
6442
6443 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6444 18 ev[0] = ringpower(dmg)*10000;
6445
6446 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6447 18 dmg = ev[0]/10000;
6448 18 int32_t hdir = ev[1]/10000;
6449 18 nullhit = ev[2] != 0;
6450 18 bool nayrulove = ev[3] != 0;
6451 18 int32_t iframes = ev[4] / 10000;
6452 18 ev.clear();
6453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) return;
6454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!nayrulove)
6455 {
6456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 game->set_life(zc_max(game->get_life()-dmg,0));
6457 18 }
6458
6459 18 hitdir = hdir;
6460
6461
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
18 if (action != rafting && action != freeze && action != sideswimfreeze)
6462 {
6463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (IsSideSwim())
6464 {
6465 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6466 }
6467
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 else if (action == swimming || hopclk == 0xFF)
6468 {
6469 action=swimhit; FFCore.setHeroAction(swimhit);
6470 }
6471 else
6472 {
6473 18 action=gothit; FFCore.setHeroAction(gothit);
6474 }
6475 18 }
6476
6477
5/8
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
18 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6478 {
6479 5 spins = charging = attackclk = 0;
6480 5 attack=none;
6481 5 tapping = false;
6482 5 }
6483
6484 18 hclk=iframes;
6485 18 sfx(getHurtSFX(),pan(x.getInt()));
6486 18 return;
6487 }
6488 1457947 }
6489
6490 // check enemy weapons true, 1, -1
6491 //
6492
2/2
✓ Branch 0 taken 1854586 times.
✓ Branch 1 taken 15795 times.
1870381 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6493 {
6494
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15795 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15795 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6495 {
6496
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6497 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6498 15795 itemid = vbound(itemid, 0, MAXITEMS-1);
6499
6500
2/2
✓ Branch 0 taken 15791 times.
✓ Branch 1 taken 1039 times.
16830 for(int32_t j=0; j<Ewpns.Count(); j++)
6501 {
6502 1039 sprite *t = Ewpns.spr(j);
6503
6504
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 4 times.
1039 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6505 {
6506 4 bool reflect = false;
6507 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6508
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 switch(t->id)
6509 {
6510 case ewBrang:
6511 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6512
6513 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6514 goto killweapon;
6515
6516 case ewArrow:
6517 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6518
6519 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6520 goto killweapon;
6521
6522 case ewRock:
6523 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6524
6525 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6526 goto killweapon;
6527
6528 case ewFireball2:
6529 case ewFireball:
6530 {
6531 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6532
6533 if(!(itemsbuf[itemid].misc3 & mask)) break;
6534
6535 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6536 goto killweapon;
6537 }
6538
6539 case ewSword:
6540 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6541
6542 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6543 goto killweapon;
6544
6545 case wRefMagic:
6546 case ewMagic:
6547 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6548
6549 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6550 goto killweapon;
6551
6552 case wScript1:
6553 case wScript2:
6554 case wScript3:
6555 case wScript4:
6556 case wScript5:
6557 case wScript6:
6558 case wScript7:
6559 case wScript8:
6560 case wScript9:
6561 case wScript10:
6562 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6563
6564 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6565 goto killweapon;
6566
6567 case ewLitBomb:
6568 case ewLitSBomb:
6569 killweapon:
6570 ((weapon*)s)->dead=1;
6571 weapon *ew = ((weapon*)t);
6572 int32_t oldid = ew->id;
6573 ew->onhit(true, reflect ? 2 : 1, s->dir);
6574
6575 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6576 {
6577 Lwpns.add(ew);
6578 Ewpns.remove(ew);
6579 ew->isLWeapon = true; //Make sure this gets set everywhere!
6580 }
6581
6582 if(ew->id==wRefMagic)
6583 {
6584 ew->ignoreHero=true;
6585 ew->ignorecombo=-1;
6586 }
6587
6588 break;
6589 }
6590
6591 4 break;
6592 }
6593 1035 }
6594 15795 }
6595 15795 }
6596
6597
6/6
✓ Branch 0 taken 1331779 times.
✓ Branch 1 taken 538602 times.
✓ Branch 2 taken 353122 times.
✓ Branch 3 taken 978657 times.
✓ Branch 4 taken 8405 times.
✓ Branch 5 taken 344717 times.
1870381 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6598 {
6599
7/10
✓ Branch 0 taken 546903 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 547006 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
547007 if(((s->id==wBomb)||(s->id==wSBomb)) && s->hit(this) && !superman && (scriptcoldet&1) && !fallclk)
6600 {
6601 1 std::vector<int32_t> &ev = FFCore.eventData;
6602 1 ev.clear();
6603
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6604 1 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6605 1 ev.push_back(0);
6606 1 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6607 1 ev.push_back(48*10000);
6608 1 ev.push_back(ZSD_LWPN*10000);
6609 1 ev.push_back(s->getUID());
6610
6611 1 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6612 1 int32_t dmg = ev[0]/10000;
6613 1 bool nullhit = ev[2] != 0;
6614
6615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(nullhit) {ev.clear(); return;}
6616
6617 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6618 1 ev[0] = ringpower(dmg)*10000;
6619
6620 1 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6621 1 dmg = ev[0]/10000;
6622 1 int32_t hdir = ev[1]/10000;
6623 1 nullhit = ev[2] != 0;
6624 1 bool nayrulove = ev[3] != 0;
6625 1 int32_t iframes = ev[4] / 10000;
6626 1 ev.clear();
6627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(nullhit) return;
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!nayrulove)
6629 {
6630
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6631 1 }
6632
6633 1 hitdir = hdir;
6634
6635
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (action != rafting && action != freeze && action != sideswimfreeze)
6636 {
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (IsSideSwim())
6638 {
6639 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6640 }
6641
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 else if (action == swimming || hopclk == 0xFF)
6642 {
6643 action=swimhit; FFCore.setHeroAction(swimhit);
6644 }
6645 else
6646 {
6647 1 action=gothit; FFCore.setHeroAction(gothit);
6648 }
6649 1 }
6650
6651
4/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6652 {
6653 spins = charging = attackclk = 0;
6654 attack=none;
6655 tapping = false;
6656 }
6657
6658 1 hclk=iframes;
6659 1 sfx(getHurtSFX(),pan(x.getInt()));
6660 1 return;
6661 }
6662 547006 }
6663
6664
7/8
✓ Branch 0 taken 1870380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3335 times.
✓ Branch 3 taken 1867045 times.
✓ Branch 4 taken 3314 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 1870359 times.
✓ Branch 7 taken 21 times.
1870380 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6665 {
6666 21 std::vector<int32_t> &ev = FFCore.eventData;
6667 21 ev.clear();
6668 21 ev.push_back(0);
6669 21 ev.push_back(s->dir*10000);
6670 21 ev.push_back(0);
6671 21 ev.push_back(0);
6672 21 ev.push_back(ZSD_LWPN*10000);
6673 21 ev.push_back(s->getUID());
6674
6675 21 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6676 21 bool nullhit = ev[2] != 0;
6677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(nullhit) {ev.clear(); return;}
6678
6679 21 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6680 21 int32_t hdir = ev[1]/10000;
6681 21 nullhit = ev[2] != 0;
6682 21 ev.clear();
6683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(nullhit) return;
6684
6685 21 reset_hookshot();
6686 21 xofs=1000;
6687 21 action=inwind; FFCore.setHeroAction(inwind);
6688 21 dir=s->dir=hdir;
6689 21 spins = charging = attackclk = 0;
6690
6691 // In case Hero used two whistles in a row, summoning two whirlwinds,
6692 // check which whistle's whirlwind picked him up so the correct
6693 // warp ring will be used
6694 21 int32_t whistle=((weapon*)s)->parentitem;
6695
6696
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6697 21 whistleitem=whistle;
6698
6699 21 return;
6700 }
6701 1870359 }
6702
6703
6/8
✓ Branch 0 taken 3389771 times.
✓ Branch 1 taken 17050 times.
✓ Branch 2 taken 3341931 times.
✓ Branch 3 taken 47840 times.
✓ Branch 4 taken 3341931 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3341931 times.
6748752 if(action==rafting || action==freeze || action==sideswimfreeze ||
6704
4/8
✓ Branch 0 taken 3341931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3341931 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3341931 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3341931 times.
✗ Branch 7 not taken.
3341931 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6705 64890 return;
6706
6707 3341931 int32_t hit2 = -1;
6708 3341931 do
6709 {
6710
2/2
✓ Branch 0 taken 481622 times.
✓ Branch 1 taken 2863048 times.
3344670 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6711 2863048 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6712
6713
2/2
✓ Branch 0 taken 3335305 times.
✓ Branch 1 taken 9365 times.
3344670 if(hit2!=-1)
6714 {
6715
2/2
✓ Branch 0 taken 2739 times.
✓ Branch 1 taken 6626 times.
9365 if (hithero(hit2) == 0) return;
6716 2739 }
6717
2/2
✓ Branch 0 taken 2739 times.
✓ Branch 1 taken 3335305 times.
3338044 } while (hit2 != -1);
6718
6/6
✓ Branch 0 taken 3234673 times.
✓ Branch 1 taken 100632 times.
✓ Branch 2 taken 3222637 times.
✓ Branch 3 taken 12036 times.
✓ Branch 4 taken 173 times.
✓ Branch 5 taken 3222464 times.
3335305 if (superman || !(scriptcoldet&1) || fallclk) return;
6719 3222464 hit2 = LwpnHit();
6720
6721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3222464 times.
3222464 if(hit2!=-1)
6722 {
6723 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6724 std::vector<int32_t> &ev = FFCore.eventData;
6725 ev.clear();
6726 ev.push_back((lwpn_dp(hit2)*10000));
6727 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6728 ev.push_back(0);
6729 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6730 ev.push_back(48*10000);
6731 ev.push_back(ZSD_LWPN*10000);
6732 ev.push_back(lwpnspr->getUID());
6733
6734 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6735 int32_t dmg = ev[0]/10000;
6736 bool nullhit = ev[2] != 0;
6737
6738 if(nullhit) {ev.clear(); return;}
6739
6740 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6741 ev[0] = ringpower(dmg)*10000;
6742
6743 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6744 dmg = ev[0]/10000;
6745 int32_t hdir = ev[1]/10000;
6746 nullhit = ev[2] != 0;
6747 bool nayrulove = ev[3] != 0;
6748 int32_t iframes = ev[4] / 10000;
6749 ev.clear();
6750 if(nullhit) return;
6751 if(!nayrulove)
6752 {
6753 game->set_life(zc_max(game->get_life()-dmg,0));
6754 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6755 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6756 }
6757
6758 hitdir = hdir;
6759 lwpnspr->onhit(false);
6760
6761 if (IsSideSwim())
6762 {
6763 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6764 }
6765 else if(action==swimming || hopclk==0xFF)
6766 {
6767 action=swimhit; FFCore.setHeroAction(swimhit);
6768 }
6769 else
6770 {
6771 action=gothit; FFCore.setHeroAction(gothit);
6772 }
6773
6774 hclk=iframes;
6775
6776 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6777 {
6778 spins = charging = attackclk = 0;
6779 attack=none;
6780 tapping = false;
6781 }
6782
6783 sfx(getHurtSFX(),pan(x.getInt()));
6784 return;
6785 }
6786
6787 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6788
6789 3222464 hit2 = EwpnHit();
6790
6791
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 3220409 times.
3222464 if(hit2!=-1)
6792 {
6793 2055 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6794 2055 std::vector<int32_t> &ev = FFCore.eventData;
6795 2055 ev.clear();
6796 2055 ev.push_back((ewpn_dp(hit2)*10000));
6797 2055 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6798 2055 ev.push_back(0);
6799 2055 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6800 2055 ev.push_back(48*10000);
6801 2055 ev.push_back(ZSD_EWPN*10000);
6802 2055 ev.push_back(ewpnspr->getUID());
6803
6804 2055 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6805 2055 int32_t dmg = ev[0]/10000;
6806 2055 bool nullhit = ev[2] != 0;
6807
6808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
2055 if(nullhit) {ev.clear(); return;}
6809
6810 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6811 2055 ev[0] = ringpower(dmg)*10000;
6812
6813 2055 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6814 2055 dmg = ev[0]/10000;
6815 2055 int32_t hdir = ev[1]/10000;
6816 2055 nullhit = ev[2] != 0;
6817 2055 bool nayrulove = ev[3] != 0;
6818 2055 int32_t iframes = ev[4] / 10000;
6819 2055 ev.clear();
6820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
2055 if(nullhit) return;
6821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
2055 if(!nayrulove)
6822 {
6823
2/2
✓ Branch 0 taken 2045 times.
✓ Branch 1 taken 10 times.
2055 game->set_life(zc_max(game->get_life()-dmg,0));
6824 2055 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6825 2055 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6826 2055 }
6827
6828 2055 hitdir = hdir;
6829 2055 ewpnspr->onhit(false);
6830
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
2055 if (IsSideSwim())
6832 {
6833 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6834 }
6835
3/4
✓ Branch 0 taken 2046 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2046 times.
2055 else if(action==swimming || hopclk==0xFF)
6836 {
6837 9 action=swimhit; FFCore.setHeroAction(swimhit);
6838 9 }
6839 else
6840 {
6841 2046 action=gothit; FFCore.setHeroAction(gothit);
6842 }
6843
6844 2055 hclk=iframes;
6845
6846
6/8
✓ Branch 0 taken 2052 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2052 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 577 times.
✓ Branch 5 taken 1475 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 577 times.
2055 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6847 {
6848 1478 spins = charging = attackclk = 0;
6849 1478 attack=none;
6850 1478 tapping = false;
6851 1478 }
6852
6853 2055 sfx(getHurtSFX(),pan(x.getInt()));
6854 2055 return;
6855 }
6856 //else { sethitHeroUID(HIT_BY_EWEAPON,(0)); } //fails to clear
6857
6858 // The rest of this method deals with damage combos, which can be jumped over.
6859
4/4
✓ Branch 0 taken 3217141 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 3217141 times.
✓ Branch 3 taken 3268 times.
3220409 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6860
6861 3217141 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6862 3217141 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3217141 times.
3217141 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3217141 times.
3217141 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6865
6866
2/2
✓ Branch 0 taken 3217141 times.
✓ Branch 1 taken 6729249 times.
9946390 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6867 6729249 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6868 3628965 }
6869
6870 3011 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6871 {
6872 3011 return checkdamagecombos(dx,dx,dy,dy);
6873 }
6874
6875 98 void HeroClass::doHit(int32_t hdir)
6876 {
6877 98 hitdir = hdir;
6878
6879
3/6
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 98 times.
98 if (action != rafting && action != freeze && action != sideswimfreeze)
6880 {
6881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if (IsSideSwim())
6882 {
6883 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6884 }
6885
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 else if (action == swimming || hopclk == 0xFF)
6886 {
6887 action=swimhit; FFCore.setHeroAction(swimhit);
6888 }
6889 else
6890 {
6891 98 action=gothit; FFCore.setHeroAction(gothit);
6892 }
6893 98 }
6894
6895 98 hclk=48;
6896
6897
5/8
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✓ Branch 5 taken 38 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 60 times.
98 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6898 {
6899 38 spins = charging = attackclk = 0;
6900 38 attack=none;
6901 38 tapping = false;
6902 38 }
6903
6904 98 sfx(getHurtSFX(),pan(x.getInt()));
6905 98 }
6906
6907 7578170 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6908 {
6909
5/6
✓ Branch 0 taken 7578165 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 7573281 times.
✓ Branch 3 taken 4884 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7573281 times.
7578170 if(hclk || superman || fallclk)
6910 4889 return false;
6911
6912 7573281 int32_t hp_mod[4] = {0};
6913 int32_t cid[8];
6914 7573281 byte hasKB = 0;
6915
6916 {
6917
2/2
✓ Branch 0 taken 4072719 times.
✓ Branch 1 taken 3500562 times.
7573281 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6918 7573281 newcombo& cmb = combobuf[cid[0]];
6919
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7573208 times.
✓ Branch 3 taken 73 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6920 {
6921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(cmb.usrflags&cflag1)
6922 hp_mod[0] = cmb.attributes[0] / -10000L;
6923 else
6924 73 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(!(cmb.usrflags&cflag2))
6926 73 hasKB |= 1<<0;
6927 73 }
6928 }
6929 {
6930
2/2
✓ Branch 0 taken 4072719 times.
✓ Branch 1 taken 3500562 times.
7573281 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6931 7573281 newcombo& cmb = combobuf[cid[1]];
6932
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7573193 times.
✓ Branch 3 taken 88 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6933 {
6934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(cmb.usrflags&cflag1)
6935 hp_mod[1] = cmb.attributes[0] / -10000L;
6936 else
6937 88 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!(cmb.usrflags&cflag2))
6939 88 hasKB |= 1<<1;
6940 88 }
6941 }
6942 {
6943
2/2
✓ Branch 0 taken 4072719 times.
✓ Branch 1 taken 3500562 times.
7573281 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6944 7573281 newcombo& cmb = combobuf[cid[2]];
6945
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7573202 times.
✓ Branch 3 taken 79 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6946 {
6947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(cmb.usrflags&cflag1)
6948 hp_mod[2] = cmb.attributes[0] / -10000L;
6949 else
6950 79 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(!(cmb.usrflags&cflag2))
6952 79 hasKB |= 1<<2;
6953 79 }
6954 }
6955 {
6956
2/2
✓ Branch 0 taken 4072719 times.
✓ Branch 1 taken 3500562 times.
7573281 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6957 7573281 newcombo& cmb = combobuf[cid[3]];
6958
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7573190 times.
✓ Branch 3 taken 91 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6959 {
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
91 if(cmb.usrflags&cflag1)
6961 hp_mod[3] = cmb.attributes[0] / -10000L;
6962 else
6963 91 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
91 if(!(cmb.usrflags&cflag2))
6965 91 hasKB |= 1<<3;
6966 91 }
6967 }
6968
6969 7573281 int32_t bestcid=0;
6970 7573281 int32_t hp_modtotal=0;
6971
2/2
✓ Branch 0 taken 4957075 times.
✓ Branch 1 taken 2616206 times.
7573281 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6972
2/2
✓ Branch 0 taken 4955015 times.
✓ Branch 1 taken 2618266 times.
7573281 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6973
2/2
✓ Branch 0 taken 4957107 times.
✓ Branch 1 taken 2616174 times.
7573281 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6974
2/2
✓ Branch 0 taken 4955048 times.
✓ Branch 1 taken 2618233 times.
7573281 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6975
6976
2/2
✓ Branch 0 taken 15146562 times.
✓ Branch 1 taken 7573281 times.
22719843 for (int32_t i = 0; i <= 1; ++i)
6977 {
6978
2/2
✓ Branch 0 taken 10624129 times.
✓ Branch 1 taken 4522433 times.
15146562 if(tmpscr2[i].valid!=0)
6979 {
6980
2/2
✓ Branch 0 taken 4203586 times.
✓ Branch 1 taken 318847 times.
4522433 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6981 {
6982
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6985
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6986 4203586 }
6987 else
6988 {
6989
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6990
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6991
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6992
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6993 }
6994 4522433 }
6995 15146562 }
6996
6997
2/2
✓ Branch 0 taken 30293124 times.
✓ Branch 1 taken 7573281 times.
37866405 for(int32_t i=0; i<4; i++)
6998 {
6999
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 14768732 times.
30293124 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7000 {
7001
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7002 {
7003
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotal)
7004 {
7005 63 hp_modtotal = hp_mod[i];
7006 63 bestcid = cid[i];
7007 63 }
7008 15524232 }
7009
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7010 {
7011
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotal)
7012 {
7013 hp_modtotal = hp_mod[i];
7014 bestcid = cid[i];
7015 }
7016 139 }
7017 15524392 }
7018
2/2
✓ Branch 0 taken 14768693 times.
✓ Branch 1 taken 39 times.
14768732 else if(hp_mod[i] < hp_modtotal)
7019 {
7020 39 hp_modtotal = hp_mod[i];
7021 39 bestcid = cid[i];
7022 39 }
7023 30293124 }
7024
7025 {
7026 7573281 cid[4] = MAPFFCOMBO(dx1,dy1);
7027 7573281 newcombo& cmb = combobuf[cid[4]];
7028
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7572931 times.
✓ Branch 3 taken 350 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7029 {
7030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if(cmb.usrflags&cflag1 )
7031 hp_mod[0] = cmb.attributes[0]/10000L;
7032 else
7033 350 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7034
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(!(cmb.usrflags&cflag2))
7035 hasKB |= 1<<4;
7036 350 }
7037 }
7038 {
7039 7573281 cid[5] = MAPFFCOMBO(dx1,dy2);
7040 7573281 newcombo& cmb = combobuf[cid[5]];
7041
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7572940 times.
✓ Branch 3 taken 341 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7042 {
7043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7044 hp_mod[1] = cmb.attributes[0]/10000L;
7045 else
7046 341 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7047
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7048 hasKB |= 1<<5;
7049 341 }
7050 }
7051 {
7052 7573281 cid[6] = MAPFFCOMBO(dx2,dy1);
7053 7573281 newcombo& cmb = combobuf[cid[6]];
7054
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7572919 times.
✓ Branch 3 taken 362 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7055 {
7056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 if(cmb.usrflags&cflag1 )
7057 hp_mod[2] = cmb.attributes[0]/10000L;
7058 else
7059 362 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7060
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if(!(cmb.usrflags&cflag2))
7061 hasKB |= 1<<6;
7062 362 }
7063 }
7064 {
7065 7573281 cid[7] = MAPFFCOMBO(dx2,dy2);
7066 7573281 newcombo& cmb = combobuf[cid[7]];
7067
3/4
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7572940 times.
✓ Branch 3 taken 341 times.
7573281 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7068 {
7069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7070 hp_mod[3] = cmb.attributes[0]/10000L;
7071 else
7072 341 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7073
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7074 hasKB |= 1<<7;
7075 341 }
7076 }
7077
7078 7573281 int32_t bestffccid = 0;
7079 7573281 int32_t hp_modtotalffc = 0;
7080
7081
2/2
✓ Branch 0 taken 15146562 times.
✓ Branch 1 taken 7573281 times.
22719843 for (int32_t i = 0; i <= 1; ++i)
7082 {
7083
2/2
✓ Branch 0 taken 10624129 times.
✓ Branch 1 taken 4522433 times.
15146562 if(tmpscr2[i].valid!=0)
7084 {
7085
2/2
✓ Branch 0 taken 4203586 times.
✓ Branch 1 taken 318847 times.
4522433 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7086 {
7087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4203586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4203586 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7091 4203586 }
7092 else
7093 {
7094
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7095
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7096
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7097
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7098 }
7099 4522433 }
7100 15146562 }
7101
7102
2/2
✓ Branch 0 taken 30293124 times.
✓ Branch 1 taken 7573281 times.
37866405 for(int32_t i=0; i<4; i++)
7103 {
7104
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 14768732 times.
30293124 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7105 {
7106
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotalffc >= 0)
7107 {
7108
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotalffc)
7109 {
7110 63 hp_modtotalffc = hp_mod[i];
7111 63 bestffccid = cid[4+i];
7112 63 }
7113 15524232 }
7114
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0)
7115 {
7116
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotalffc)
7117 {
7118 hp_modtotalffc = hp_mod[i];
7119 bestffccid = cid[4+i];
7120 }
7121 139 }
7122 15524392 }
7123
2/2
✓ Branch 0 taken 14768310 times.
✓ Branch 1 taken 422 times.
14768732 else if(hp_mod[i] < hp_modtotalffc)
7124 {
7125 422 hp_modtotalffc = hp_mod[i];
7126 422 bestffccid = cid[4+i];
7127 422 }
7128 30293124 }
7129
7130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7573281 times.
7573281 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7131
1/2
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
7573281 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7132
7133 7573281 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7134 7573281 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7135 7573281 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7136
1/2
✓ Branch 0 taken 7573281 times.
✗ Branch 1 not taken.
7573281 if(current_ring)
7137 {
7138 global_defring = !global_defring;
7139 global_perilring = !global_perilring;
7140 }
7141 7573281 int32_t itemid = current_item_id(itype_boots);
7142
7143
2/2
✓ Branch 0 taken 7523699 times.
✓ Branch 1 taken 49582 times.
7573281 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7144
2/2
✓ Branch 0 taken 7523699 times.
✓ Branch 1 taken 49582 times.
7573281 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7145
7146
2/2
✓ Branch 0 taken 7572796 times.
✓ Branch 1 taken 485 times.
7573281 if(hp_modmin<0)
7147 {
7148
8/14
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 374 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 374 times.
✓ Branch 10 taken 374 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 374 times.
485 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7149 {
7150
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 14 times.
111 if (!do_health_check) return true;
7151 97 std::vector<int32_t> &ev = FFCore.eventData;
7152 97 ev.clear();
7153 97 ev.push_back(-hp_modmin*10000);
7154
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 3 times.
97 ev.push_back((hasKB ? dir^1 : -1)*10000);
7155 97 ev.push_back(0);
7156 97 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7157 97 ev.push_back(48*10000);
7158 97 ev.push_back(ZSD_COMBODATA*10000);
7159 97 ev.push_back(bestcid);
7160
7161 97 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7162 97 int32_t dmg = ev[0]/10000;
7163 97 bool nullhit = ev[2] != 0;
7164
7165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(nullhit) {ev.clear(); return false;}
7166
7167 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7168 97 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7169
7170 97 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7171 97 dmg = ev[0]/10000;
7172 97 int32_t hdir = ev[1]/10000;
7173 97 nullhit = ev[2] != 0;
7174 97 bool nayrulove = ev[3] != 0;
7175 97 int32_t iframes = ev[4] / 10000;
7176 97 ev.clear();
7177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(nullhit) return false;
7178
7179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!nayrulove)
7180 {
7181
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 2 times.
97 game->set_life(zc_max(game->get_life()-dmg,0));
7182 97 }
7183
7184 97 hitdir = hdir;
7185 97 doHit(hitdir);
7186 97 hclk = iframes;
7187 97 return true;
7188 }
7189
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 50 times.
374 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7190 374 }
7191
7192 7573170 return false;
7193 7578170 }
7194
7195 9424 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7196 {
7197
1/2
✓ Branch 0 taken 9424 times.
✗ Branch 1 not taken.
9424 if(force_hdir > 3) force_hdir = -1;
7198 9424 enemy* enemyptr = (enemy*)guys.spr(hit2);
7199
1/2
✓ Branch 0 taken 9424 times.
✗ Branch 1 not taken.
9424 if(!enemyptr) return 0;
7200 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7201 9424 int32_t stompid = current_item_id(itype_stompboots);
7202
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 9424 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9424 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7203 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7204 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7205 {
7206 paymagiccost(stompid);
7207 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7208
7209 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7210 {
7211 fall = -(itemsbuf[stompid].misc1);
7212 }
7213
7214 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7215 game->set_item(stompid,false);
7216
7217 // Stomp Boots script
7218 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7219 {
7220 //clear the item script stack for a new script
7221 ri = &(itemScriptData[stompid]);
7222 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7223 ri->Clear();
7224 //itemScriptData[(stompid & 0xFFF)].Clear();
7225 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7226 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7227 item_doscript[stompid] = 1;
7228 itemscriptInitialised[stompid] = 0;
7229 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7230 }
7231
7232 return -1;
7233 }
7234
5/6
✓ Branch 0 taken 6175 times.
✓ Branch 1 taken 3249 times.
✓ Branch 2 taken 5222 times.
✓ Branch 3 taken 953 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5222 times.
9424 else if(superman || !(scriptcoldet&1) || fallclk)
7235 4202 return 0;
7236 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7237 //!Add a flag check to this if:
7238
5/6
✓ Branch 0 taken 2692 times.
✓ Branch 1 taken 2530 times.
✓ Branch 2 taken 2692 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1769 times.
✓ Branch 5 taken 923 times.
5222 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7239
3/4
✓ Branch 0 taken 1541 times.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2464 times.
2692 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7240 {
7241 2758 return -1;
7242 }
7243
7244 2464 std::vector<int32_t> &ev = FFCore.eventData;
7245 2464 ev.clear();
7246 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7247 2464 ev.push_back((enemy_dp(hit2) *10000));
7248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
2464 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7249 2464 ev.push_back(0);
7250 2464 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7251 2464 ev.push_back(48*10000);
7252 2464 ev.push_back(ZSD_NPC*10000);
7253 2464 ev.push_back(enemyptr->getUID());
7254
7255 2464 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7256 2464 int32_t dmg = ev[0] / 10000;
7257 2464 bool nullhit = ev[2] != 0;
7258
7259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
2464 if(nullhit) {ev.clear(); return -1;}
7260
7261 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7262 2464 ev[0] = ((ringpower(dmg)*10000));
7263
7264 2464 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7265 2464 dmg = ev[0] / 10000;
7266 2464 int32_t hdir = ev[1] / 10000;
7267 2464 nullhit = ev[2] != 0;
7268 2464 bool nayrulove = ev[3] != 0;
7269 2464 int32_t iframes = ev[4] / 10000;
7270 2464 ev.clear();
7271
7272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
2464 if(nullhit) return -1;
7273
7274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
2464 if(!nayrulove)
7275 {
7276
2/2
✓ Branch 0 taken 2445 times.
✓ Branch 1 taken 19 times.
2464 game->set_life(zc_max(game->get_life()-dmg,0));
7277 2464 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7278 2464 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7279 2464 }
7280
7281 2464 hitdir = hdir;
7282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
2464 if (IsSideSwim())
7283 {
7284 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7285 }
7286
3/4
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2446 times.
2464 else if(action==swimming || hopclk==0xFF)
7287 {
7288 18 action=swimhit; FFCore.setHeroAction(swimhit);
7289 18 }
7290 else
7291 {
7292 2446 action=gothit; FFCore.setHeroAction(gothit);
7293 }
7294
7295 2464 hclk=iframes;
7296 2464 sfx(getHurtSFX(),pan(x.getInt()));
7297
7298
7/8
✓ Branch 0 taken 2462 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 770 times.
✓ Branch 5 taken 1692 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 762 times.
2464 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7299 {
7300 1702 spins = charging = attackclk = 0;
7301 1702 attack=none;
7302 1702 tapping = false;
7303 1702 }
7304
7305 2464 enemy_scored(hit2);
7306 2464 int32_t dm7 = enemyptr->dmisc7;
7307 2464 int32_t dm8 = enemyptr->dmisc8;
7308
7309
3/3
✓ Branch 0 taken 1175 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1286 times.
2464 switch(enemyptr->family)
7310 {
7311 case eeWALLM:
7312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(enemyptr->hp>0)
7313 {
7314 3 GrabHero(hit2);
7315 3 inwallm=true;
7316 3 action=none; FFCore.setHeroAction(none);
7317 3 }
7318 3 break;
7319
7320 //case eBUBBLEST:
7321 //case eeBUBBLE:
7322 case eeWALK:
7323 {
7324 1286 int32_t itemid = current_item_id(itype_whispring);
7325 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7326
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
1286 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7327
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
1286 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7328
7329
5/7
✓ Branch 0 taken 986 times.
✓ Branch 1 taken 175 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
1286 switch(dm7)
7330 {
7331 case e7tTEMPJINX:
7332
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
175 if(dm8==0 || dm8==2)
7333
4/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 152 times.
308 if(swordclk>=0 && !(sworddivisor==0))
7334 152 swordclk=150;
7335
7336
3/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 156 times.
175 if(dm8==1 || dm8==2)
7337
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 18 times.
37 if(itemclk>=0 && !(itemdivisor==0))
7338 18 itemclk=150;
7339
7340 175 break;
7341
7342 case e7tPERMJINX:
7343
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
46 if(dm8==0 || dm8==2)
7344
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
30 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7345
7346
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
46 if(dm8==1 || dm8==2)
7347
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
16 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7348
7349 46 break;
7350
7351 case e7tUNJINX:
7352
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
58 if(dm8==0 || dm8==2)
7353 46 swordclk=0;
7354
7355
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
58 if(dm8==1 || dm8==2)
7356 12 itemclk=0;
7357
7358 58 break;
7359
7360 case e7tTAKEMAGIC:
7361 game->change_dmagic(-dm8*game->get_magicdrainrate());
7362 break;
7363
7364 case e7tTAKERUPEES:
7365 21 game->change_drupy(-dm8);
7366 21 break;
7367
7368 case e7tDRUNK:
7369 drunkclk += dm8;
7370 break;
7371 }
7372 1286 verifyAWpn();
7373
2/2
✓ Branch 0 taken 1242 times.
✓ Branch 1 taken 44 times.
1286 if(dm7 >= e7tEATITEMS)
7374 {
7375 44 EatHero(hit2);
7376 44 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7377 44 action=none; FFCore.setHeroAction(none);
7378 44 }
7379 }
7380 1286 }
7381 2464 return 0;
7382 9424 }
7383
7384 192121 void HeroClass::addsparkle(int32_t wpn)
7385 {
7386 //return;
7387 192121 weapon *w = (weapon*)Lwpns.spr(wpn);
7388 192121 int32_t itemid = w->parentitem;
7389
7390
2/2
✓ Branch 0 taken 190593 times.
✓ Branch 1 taken 1528 times.
192121 if(itemid<0)
7391 1528 return;
7392
7393 190593 int32_t itemtype = itemsbuf[itemid].family;
7394
7395
3/4
✓ Branch 0 taken 190593 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47650 times.
✓ Branch 3 taken 142943 times.
190593 if(itemtype!=itype_cbyrna && frame%4)
7396 142943 return;
7397
7398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47650 times.
47650 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47650 times.
47650 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7400 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7401
4/8
✓ Branch 0 taken 20684 times.
✓ Branch 1 taken 26966 times.
✓ Branch 2 taken 26966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20684 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
47650 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7402 47650 int32_t direction=w->dir;
7403
7404
2/2
✓ Branch 0 taken 26966 times.
✓ Branch 1 taken 20684 times.
47650 if(sparkle_type)
7405 {
7406 20684 int32_t h=0;
7407 20684 int32_t v=0;
7408
7409
6/6
✓ Branch 0 taken 15923 times.
✓ Branch 1 taken 4761 times.
✓ Branch 2 taken 14383 times.
✓ Branch 3 taken 1540 times.
✓ Branch 4 taken 2850 times.
✓ Branch 5 taken 11533 times.
20684 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7410 {
7411 9151 h=-1;
7412 9151 }
7413
7414
6/6
✓ Branch 0 taken 16020 times.
✓ Branch 1 taken 4664 times.
✓ Branch 2 taken 13492 times.
✓ Branch 3 taken 2528 times.
✓ Branch 4 taken 1569 times.
✓ Branch 5 taken 11923 times.
20684 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7415 {
7416 8761 h=1;
7417 8761 }
7418
7419
6/6
✓ Branch 0 taken 19411 times.
✓ Branch 1 taken 1273 times.
✓ Branch 2 taken 17842 times.
✓ Branch 3 taken 1569 times.
✓ Branch 4 taken 2850 times.
✓ Branch 5 taken 14992 times.
20684 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7420 {
7421 5692 v=-1;
7422 5692 }
7423
7424
6/6
✓ Branch 0 taken 19185 times.
✓ Branch 1 taken 1499 times.
✓ Branch 2 taken 16657 times.
✓ Branch 3 taken 2528 times.
✓ Branch 4 taken 1540 times.
✓ Branch 5 taken 15117 times.
20684 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7425 {
7426 5567 v=1;
7427 5567 }
7428
7429 // Damaging boomerang sparkle?
7430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20684 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20684 if(wpn3 && itemtype==itype_brang)
7431 {
7432 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7433 // whatever it just bounced off of if it's shielded from that direction.
7434 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7435 direction=oppositeDir[direction];
7436 }
7437
3/4
✓ Branch 0 taken 20603 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20603 times.
20684 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20684 times.
20684 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20684 times.
20684 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7440
5/10
✓ Branch 0 taken 20684 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20684 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20684 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20684 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20684 times.
✗ Branch 9 not taken.
20684 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7441 20684 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7442 20684 }
7443 192121 }
7444
7445 // For wPhantoms
7446 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7447 {
7448 if(frame%4) return;
7449
7450 int32_t arrow = -1;
7451
7452 for(int32_t i=0; i<Lwpns.Count(); i++)
7453 {
7454 weapon *w = (weapon*)Lwpns.spr(i);
7455
7456 if(w->id == wPhantom && w->type == type1)
7457 {
7458 arrow = i;
7459 break;
7460 }
7461 }
7462
7463 if(arrow==-1)
7464 {
7465 return;
7466 }
7467
7468 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7469 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7470 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7471 }
7472
7473 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7474 3628643 void HeroClass::PhantomsCleanup()
7475 {
7476
1/2
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
3628643 if(Lwpns.idCount(wPhantom))
7477 {
7478 for(int32_t i=0; i<Lwpns.Count(); i++)
7479 {
7480 weapon *w = ((weapon *)Lwpns.spr(i));
7481 if ( w->id == wPhantom && !w->isScriptGenerated() )
7482 {
7483 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7484 {
7485 Lwpns.remove(w);
7486 }
7487 }
7488 }
7489 }
7490 3628643 }
7491
7492 //Waitframe handler for refilling operations
7493 4434 static void do_refill_waitframe()
7494 {
7495 4434 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7496
1/2
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
4434 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7497 {
7498 script_drawing_commands.Clear();
7499 if(DMaps[currdmap].passive_sub_script != 0)
7500 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7501 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7502 {
7503 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7504 passive_subscreen_waitdraw = false;
7505 }
7506 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7507 }
7508 4434 advanceframe(true);
7509 4434 }
7510 //Special handler if it's a "fairy revive"
7511 static void do_death_refill_waitframe()
7512 {
7513 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7514 //This script should be able to draw a 'fairy saving the player' animation -Em
7515 do_refill_waitframe();
7516 }
7517
7518 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7519 {
7520 int32_t found_unowned = -1;
7521 for(int q = 0; q < MAXITEMS; ++q)
7522 {
7523 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7524 {
7525 if(game->get_item(q))
7526 return q;
7527 if(unowned)
7528 found_unowned = q;
7529 }
7530 }
7531 return found_unowned;
7532 }
7533
7534 int32_t getPushDir(int32_t flag)
7535 {
7536 switch(flag)
7537 {
7538 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7539 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7540 case mfPUSHUINS:
7541 return up;
7542 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7543 return down;
7544 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7545 case mfPUSHLRINS: case mfPUSHLINS:
7546 return left;
7547 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7548 return right;
7549 }
7550 return -1;
7551 }
7552
7553 // returns true when game over
7554 10352097 bool HeroClass::animate(int32_t)
7555 {
7556 10352097 int32_t lsave=0;
7557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10352097 times.
10352097 if(immortal > 0)
7558 --immortal;
7559 10352097 prompt_combo = 0;
7560
2/2
✓ Branch 0 taken 6723131 times.
✓ Branch 1 taken 3628966 times.
10352097 if (onpassivedmg)
7561 {
7562 6723131 onpassivedmg=false;
7563 6723131 }
7564
1/2
✓ Branch 0 taken 3628966 times.
✗ Branch 1 not taken.
3628966 else if (damageovertimeclk)
7565 {
7566 damageovertimeclk = 0;
7567 }
7568
7569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10352097 times.
10352097 if(cheats_execute_goto)
7570 {
7571 didpit=true;
7572 pitx=x;
7573 pity=y;
7574 dowarp(3,0);
7575 cheats_execute_goto=false;
7576 solid_update(false);
7577 return false;
7578 }
7579
7580
1/2
✓ Branch 0 taken 10352097 times.
✗ Branch 1 not taken.
10352097 if(cheats_execute_light)
7581 {
7582 naturaldark = !naturaldark;
7583 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7584 cheats_execute_light = false;
7585 }
7586
7587
3/4
✓ Branch 0 taken 3628966 times.
✓ Branch 1 taken 6723131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3628966 times.
10352097 if(action!=climbcovertop&&action!=climbcoverbottom)
7588 {
7589 3628966 climb_cover_x=-1000;
7590 3628966 climb_cover_y=-1000;
7591 3628966 }
7592
7593
1/2
✓ Branch 0 taken 10352097 times.
✗ Branch 1 not taken.
10352097 if(mirror_portal)
7594 {
7595 mirror_portal->animate(0);
7596 if(abs(x - mirror_portal->x) < 12
7597 && abs(y - mirror_portal->y) < 12)
7598 {
7599 if(can_mirror_portal)
7600 {
7601 //Store some values to restore if 'warp fails'
7602 int32_t tLastEntrance = lastentrance,
7603 tLastEntranceDMap = lastentrance_dmap,
7604 tContScr = game->get_continue_scrn(),
7605 tContDMap = game->get_continue_dmap();
7606 int32_t sourcescr = currscr, sourcedmap = currdmap;
7607 zfix tx = x, ty = y, tz = z;
7608 x = mirror_portal->x;
7609 y = mirror_portal->y;
7610
7611 int32_t weff = mirror_portal->weffect,
7612 wsfx = mirror_portal->wsfx;
7613
7614 FFCore.warp_player(wtIWARP, mirror_portal->destdmap, mirror_portal->destscr,
7615 -1, -1, weff, wsfx, 0, -1);
7616
7617 if(mirrorBonk()) //Invalid landing, warp back!
7618 {
7619 action = none; FFCore.setHeroAction(none);
7620 lastentrance = tLastEntrance;
7621 lastentrance_dmap = tLastEntranceDMap;
7622 game->set_continue_scrn(tContScr);
7623 game->set_continue_dmap(tContDMap);
7624 x = tx;
7625 y = ty;
7626 z = tz;
7627 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7628 wsfx, 0, -1);
7629 can_mirror_portal = false;
7630 }
7631 else game->clear_portal(); //Remove portal once used
7632 }
7633 }
7634 else can_mirror_portal = true;
7635 }
7636
7637
3/4
✓ Branch 0 taken 3625932 times.
✓ Branch 1 taken 6726165 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3625932 times.
10352097 if(z<=8&&fakez<=8)
7638 {
7639
2/2
✓ Branch 0 taken 41776 times.
✓ Branch 1 taken 3584156 times.
3625932 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7640 {
7641 41776 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7642
2/2
✓ Branch 0 taken 41531 times.
✓ Branch 1 taken 245 times.
41776 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7643 {
7644
2/4
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
245 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7645
2/4
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
245 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7646
2/4
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
245 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7647
2/4
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
245 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7648 245 }
7649
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 41776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
41776 if(g1 && g2 && g3 && g4)
7650 {
7651 if(decorations.idCount(dTALLGRASS)==0)
7652 {
7653 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7654 }
7655 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7656 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7657 sfx(thesfx,pan((int32_t)x));
7658 }
7659 41776 }
7660 else
7661 {
7662 3584156 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7663
2/2
✓ Branch 0 taken 14558 times.
✓ Branch 1 taken 3569598 times.
3584156 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7664 {
7665
2/4
✓ Branch 0 taken 14558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14558 times.
14558 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7666
2/4
✓ Branch 0 taken 14558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14558 times.
14558 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7667 14558 }
7668
4/4
✓ Branch 0 taken 41523 times.
✓ Branch 1 taken 3542633 times.
✓ Branch 2 taken 5567 times.
✓ Branch 3 taken 35956 times.
3584156 if(g1 && g2)
7669 {
7670
2/2
✓ Branch 0 taken 35437 times.
✓ Branch 1 taken 519 times.
35956 if(decorations.idCount(dTALLGRASS)==0)
7671 {
7672
3/6
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✗ Branch 5 not taken.
519 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7673 519 }
7674 35956 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7675
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35956 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7676 sfx(thesfx,pan((int32_t)x));
7677 35956 }
7678 }
7679 3625932 }
7680
7681
2/2
✓ Branch 0 taken 6994678 times.
✓ Branch 1 taken 3357419 times.
10352097 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7682 {
7683
18/26
✓ Branch 0 taken 268430 times.
✓ Branch 1 taken 6726248 times.
✓ Branch 2 taken 268430 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 267151 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 267151 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 266447 times.
✓ Branch 9 taken 704 times.
✓ Branch 10 taken 266447 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 266447 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 266447 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 266237 times.
✓ Branch 17 taken 210 times.
✓ Branch 18 taken 266237 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 266215 times.
✓ Branch 21 taken 22 times.
✓ Branch 22 taken 266215 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 266215 times.
6994678 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7684 {
7685
2/2
✓ Branch 0 taken 243079 times.
✓ Branch 1 taken 23136 times.
290881 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7686
2/2
✓ Branch 0 taken 24666 times.
✓ Branch 1 taken 241549 times.
266215 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7687
2/2
✓ Branch 0 taken 23788 times.
✓ Branch 1 taken 878 times.
24666 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7688
2/2
✓ Branch 0 taken 23170 times.
✓ Branch 1 taken 618 times.
23788 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7689 {
7690
2/2
✓ Branch 0 taken 22979 times.
✓ Branch 1 taken 157 times.
23136 if(decorations.idCount(dRIPPLES)==0)
7691 {
7692
3/6
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
157 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7693 157 }
7694 23136 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 if (combobuf[watercheck].usrflags&cflag2)
7696 {
7697 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7698 {
7699 onpassivedmg = true;
7700 if (!damageovertimeclk)
7701 {
7702 int32_t curhp = game->get_life();
7703 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7704 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7705 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7706 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7707 {
7708 hclk = 48;
7709 hitdir = -1;
7710 action = gothit; FFCore.setHeroAction(gothit);
7711 }
7712 }
7713 if (combobuf[watercheck].attribytes[1] > 0)
7714 {
7715 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7716 else --damageovertimeclk;
7717 }
7718 else damageovertimeclk = 0;
7719 }
7720 else damageovertimeclk = 0;
7721 }
7722 23136 else damageovertimeclk = 0;
7723 23136 int32_t thesfx = combobuf[watercheck].attribytes[0];
7724
3/4
✓ Branch 0 taken 22806 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22806 times.
✗ Branch 3 not taken.
23136 if (combobuf[watercheck].type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7725 {
7726 330 thesfx = combobuf[watercheck].attribytes[5];
7727 330 }
7728
5/6
✓ Branch 0 taken 21663 times.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 21663 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12270 times.
✓ Branch 5 taken 9393 times.
23136 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7729 9393 sfx(thesfx,pan((int32_t)x));
7730 23136 }
7731 266215 }
7732 6994678 }
7733 else
7734 {
7735
7/8
✓ Branch 0 taken 4311 times.
✓ Branch 1 taken 3353108 times.
✓ Branch 2 taken 4156 times.
✓ Branch 3 taken 155 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4156 times.
✓ Branch 6 taken 3353263 times.
✓ Branch 7 taken 4156 times.
3357419 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7736 {
7737
2/2
✓ Branch 0 taken 4119 times.
✓ Branch 1 taken 37 times.
4156 if(decorations.idCount(dRIPPLES)==0)
7738 {
7739
3/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
37 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7740 37 }
7741 4156 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4156 times.
4156 if (combobuf[watercheck].usrflags&cflag2)
7743 {
7744 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7745 {
7746 onpassivedmg = true;
7747 if (!damageovertimeclk)
7748 {
7749 int32_t curhp = game->get_life();
7750 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7751 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7752 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7753 }
7754 if (combobuf[watercheck].attribytes[1] > 0)
7755 {
7756 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7757 else --damageovertimeclk;
7758 }
7759 else damageovertimeclk = 0;
7760 }
7761 else damageovertimeclk = 0;
7762 }
7763 4156 else damageovertimeclk = 0;
7764 4156 int32_t thesfx = combobuf[watercheck].attribytes[0];
7765
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4156 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7766 sfx(thesfx,pan((int32_t)x));
7767 4156 }
7768 }
7769
7770
2/2
✓ Branch 0 taken 10352069 times.
✓ Branch 1 taken 28 times.
10352097 if(stomping)
7771 28 stomping = false;
7772
7773
2/2
✓ Branch 0 taken 10351883 times.
✓ Branch 1 taken 214 times.
10352097 if(getOnSideviewLadder())
7774 {
7775
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
214 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7776 {
7777 setOnSideviewLadder(false);
7778 }
7779
2/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 214 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
7780 {
7781 setDir(up);
7782 }
7783 214 }
7784
7785
6/8
✓ Branch 0 taken 3626016 times.
✓ Branch 1 taken 6726081 times.
✓ Branch 2 taken 3625312 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 3625312 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3625312 times.
10352097 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7786 {
7787
2/2
✓ Branch 0 taken 3480977 times.
✓ Branch 1 taken 144335 times.
3625312 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7788 {
7789 144335 checkchest(cCHEST);
7790 144335 checkchest(cLOCKEDCHEST);
7791 144335 checkchest(cBOSSCHEST);
7792 144335 }
7793
2/2
✓ Branch 0 taken 3610637 times.
✓ Branch 1 taken 14675 times.
3625312 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7794 {
7795 14675 checkchest(cLOCKBLOCK);
7796 14675 checkchest(cBOSSLOCKBLOCK);
7797 14675 }
7798 3625312 }
7799 10352097 checksigns();
7800 10352097 checkgenpush();
7801
7802
4/4
✓ Branch 0 taken 3498129 times.
✓ Branch 1 taken 6853968 times.
✓ Branch 2 taken 2276 times.
✓ Branch 3 taken 3495853 times.
10352097 if(isStanding(true) && fall == 0)
7803 {
7804
1/2
✓ Branch 0 taken 3495853 times.
✗ Branch 1 not taken.
3495853 if(extra_jump_count > 0)
7805 extra_jump_count = 0;
7806 3495853 coyotetime = 0;
7807 3495853 }
7808
2/2
✓ Branch 0 taken 6725093 times.
✓ Branch 1 taken 131151 times.
6856244 else if(coyotetime < 65535)
7809 {
7810 131151 ++coyotetime;
7811 131151 }
7812
1/2
✓ Branch 0 taken 10352097 times.
✗ Branch 1 not taken.
10352097 if(can_use_item(itype_hoverboots,i_hoverboots))
7813 {
7814 int32_t hoverid = current_item_id(itype_hoverboots);
7815 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7816 {
7817 if(hoverclk < 0) hoverclk = 0;
7818 hoverflags &= ~HOV_OUT;
7819 }
7820 }
7821 10352097 bool platformfell2 = false;
7822 10352097 int32_t gravity3 = (zinit.gravity2/100);
7823 10352097 int32_t termv = (zinit.terminalv);
7824 10352097 int32_t rocs = getRocsPressed();
7825
2/2
✓ Branch 0 taken 10351030 times.
✓ Branch 1 taken 1067 times.
10352097 if (rocs != -1)
7826 {
7827 1067 itemdata const& itm = itemsbuf[rocs];
7828
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if (itm.flags & ITEM_FLAG2)
7829 {
7830 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7831 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7832 }
7833
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if (itm.flags & ITEM_FLAG5)
7834 {
7835 termv = itm.misc4;
7836 if (fall > termv) fall = termv;
7837 }
7838 1067 }
7839
2/2
✓ Branch 0 taken 257641 times.
✓ Branch 1 taken 10094456 times.
10352097 if(sideview_mode()) // Sideview gravity
7840 {
7841 //Handle falling through a platform
7842 257641 bool platformfell = false;
7843
4/4
✓ Branch 0 taken 130099 times.
✓ Branch 1 taken 127542 times.
✓ Branch 2 taken 130084 times.
✓ Branch 3 taken 15 times.
257641 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7844 {
7845
7/8
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 8 times.
15 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7846 15 y+=1; //Fall down a pixel instantly, through the platform.
7847
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(fall < 0) fall = 0;
7848
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(jumping < 0) jumping = 0;
7849 15 platformfell2 = true;
7850 15 }
7851 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7852
2/2
✓ Branch 0 taken 250696 times.
✓ Branch 1 taken 6945 times.
257641 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7853 {
7854
14/22
✓ Branch 0 taken 6055 times.
✓ Branch 1 taken 890 times.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 890 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 890 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 890 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 889 times.
✓ Branch 12 taken 889 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 889 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 889 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 889 times.
✓ Branch 20 taken 6944 times.
✓ Branch 21 taken 1 times.
7835 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7855
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
✓ Branch 2 taken 874 times.
✓ Branch 3 taken 15 times.
904 || ((y+(fall/100)<=0) &&
7856 // Extra checks if Smart Screen Scrolling is enabled
7857
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7858 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7859 {
7860 1 fall = jumping = 0; // Bumped his head
7861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7862 y -= y.getInt()%8; //fix coords
7863 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7865 {
7866 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7867 1 }
7868 1 }
7869 6945 }
7870 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7871
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 257641 times.
✓ Branch 2 taken 257641 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257641 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257641 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 257641 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 257641 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 214 times.
✓ Branch 13 taken 257427 times.
257641 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7872 {
7873
1/2
✓ Branch 0 taken 257427 times.
✗ Branch 1 not taken.
257427 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7874 //zprint2("ydif is: %d\n", ydiff);
7875 //zprint2("ydif is: %d\n", (int32_t)fall);
7876 257427 falling_oldy = y; // Stomp Boots-related variable
7877
5/8
✓ Branch 0 taken 48138 times.
✓ Branch 1 taken 209289 times.
✓ Branch 2 taken 48138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48138 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257427 times.
✗ Branch 7 not taken.
257427 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7878 {
7879 ydiff -= (y.getInt()+ydiff)%16;
7880 }
7881
4/4
✓ Branch 0 taken 68431 times.
✓ Branch 1 taken 188996 times.
✓ Branch 2 taken 66794 times.
✓ Branch 3 taken 1637 times.
257427 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7882 {
7883
2/2
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 764 times.
1637 if(ydiff > 0)
7884 {
7885
2/2
✓ Branch 0 taken 831 times.
✓ Branch 1 taken 1607 times.
2438 for(auto q = 0; q < ydiff; ++q)
7886 {
7887
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 42 times.
1607 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7888 {
7889 42 ydiff = q;
7890 42 break;
7891 }
7892 1565 }
7893 873 }
7894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 764 times.
764 else if(ydiff < 0)
7895 {
7896
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1492 times.
2256 for(auto q = 0; q > ydiff; --q)
7897 {
7898
1/2
✓ Branch 0 taken 1492 times.
✗ Branch 1 not taken.
2984 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1492 times.
1492 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7900 {
7901 ydiff = q;
7902 break;
7903 }
7904 1492 }
7905 764 }
7906 1637 }
7907 257427 y+=ydiff;
7908 257427 hs_starty+=ydiff;
7909
7910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257427 times.
257427 for(int32_t j=0; j<chainlinks.Count(); j++)
7911 {
7912 chainlinks.spr(j)->y+=ydiff;
7913 }
7914
7915
1/2
✓ Branch 0 taken 257427 times.
✗ Branch 1 not taken.
257427 if(Lwpns.idFirst(wHookshot)>-1)
7916 {
7917 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7918 }
7919
7920
1/2
✓ Branch 0 taken 257427 times.
✗ Branch 1 not taken.
257427 if(Lwpns.idFirst(wHSHandle)>-1)
7921 {
7922 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7923 }
7924 257427 }
7925
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
214 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7926 {
7927 fall = hoverclk = jumping = 0;
7928 inair = false;
7929 hoverflags = 0;
7930 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7931 {
7932 WalkflagInfo info;
7933 if (game->get_watergrav()<0)
7934 {
7935 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7936 execute(info);
7937 }
7938 else
7939 {
7940 info = walkflag(x,y+15+2,2,down);
7941 execute(info);
7942 }
7943 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7944 }
7945 }
7946 // Stop hovering/falling if you land on something.
7947 257641 bool needFall = false;
7948
7/8
✓ Branch 0 taken 127050 times.
✓ Branch 1 taken 130591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 257641 times.
✓ Branch 4 taken 130805 times.
✓ Branch 5 taken 126836 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 130792 times.
257641 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7949 {
7950 130792 stop_item_sfx(itype_hoverboots);
7951
1/2
✓ Branch 0 taken 124016 times.
✗ Branch 1 not taken.
254808 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7952
2/2
✓ Branch 0 taken 126660 times.
✓ Branch 1 taken 4132 times.
130792 && !getOnSideviewLadder()
7953
3/4
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
126660 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
7954 126660 y-=(int32_t)y%8; //fix position
7955 130792 fall = hoverclk = jumping = 0;
7956 130792 inair = false;
7957 130792 hoverflags = 0;
7958
7959
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 130784 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
130792 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
7960 8 y = 160;
7961 130792 }
7962 // Stop hovering if you press down.
7963
3/6
✓ Branch 0 taken 126849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126849 times.
✗ Branch 5 not taken.
126849 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
7964 {
7965 stop_item_sfx(itype_hoverboots);
7966 hoverclk = -hoverclk;
7967 reset_ladder();
7968 fall = gravity3;
7969 inair = false;
7970 }
7971
10/12
✓ Branch 0 taken 126849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3583 times.
✓ Branch 3 taken 123266 times.
✓ Branch 4 taken 1832 times.
✓ Branch 5 taken 1751 times.
✓ Branch 6 taken 1824 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1824 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 281 times.
✓ Branch 11 taken 1543 times.
126849 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim() && justmoved <= 0)
7972 {
7973 1543 zfix my = y + 4;
7974 1543 needFall = true;
7975
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 3103 times.
3751 for (zfix ty = y+1; ty < my; ++ty)
7976 {
7977 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
7978
2/2
✓ Branch 0 taken 2208 times.
✓ Branch 1 taken 895 times.
3103 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
7979 {
7980 895 y = ty;
7981
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 746 times.
895 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
7982 {
7983
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 9 times.
746 if(!slopeid)
7984 9 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
7985 746 onplatid = 5;
7986 746 }
7987 895 needFall = false;
7988 895 break;
7989 }
7990 2208 }
7991 1543 }
7992 125306 else needFall = true;
7993 // Continue falling.
7994
7995
4/4
✓ Branch 0 taken 250266 times.
✓ Branch 1 taken 7375 times.
✓ Branch 2 taken 131687 times.
✓ Branch 3 taken 118579 times.
257641 if(fall <= termv && needFall)
7996 {
7997 118579 inair = true;
7998
3/4
✓ Branch 0 taken 47130 times.
✓ Branch 1 taken 71449 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47130 times.
118579 if(fall != 0 || hoverclk>0)
7999 71449 jumping++;
8000
8001 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8002
2/2
✓ Branch 0 taken 116656 times.
✓ Branch 1 taken 1923 times.
118579 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8003 {
8004
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8005
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8006 // Extra checks if Smart Screen Scrolling is enabled
8007
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8008 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8009
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8010 {
8011 591 fall = jumping = 0; // Bumped his head
8012
8013 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8014
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8015 {
8016 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8017 110 }
8018 591 }
8019 116656 }
8020 else
8021 {
8022
8/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1923 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1923 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1923 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1923 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1923 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1923 times.
✓ Branch 14 taken 1923 times.
✗ Branch 15 not taken.
3846 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8023
3/4
✓ Branch 0 taken 1923 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 1904 times.
1923 || ((y<=0) &&
8024 // Extra checks if Smart Screen Scrolling is enabled
8025
2/6
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8026 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8027 && fall < 0)
8028 {
8029 fall = jumping = 0; // Bumped his head
8030 y -= y.getInt()%8; //fix coords
8031 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8032 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8033 {
8034 checkdamagecombos(x+4, x+12, y-1, y-1);
8035 }
8036 }
8037 }
8038
8039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118579 times.
118579 if(hoverclk > 0)
8040 {
8041 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8042 {
8043 --hoverclk;
8044 }
8045
8046 if(!hoverclk && !ladderx && !laddery)
8047 {
8048 fall += gravity3;
8049 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8050 }
8051 }
8052
5/12
✓ Branch 0 taken 85854 times.
✓ Branch 1 taken 32725 times.
✓ Branch 2 taken 47827 times.
✓ Branch 3 taken 38027 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47827 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
118579 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8053 {
8054 int32_t itemid = current_item_id(itype_hoverboots);
8055 if(hoverclk < 0)
8056 hoverclk = -hoverclk;
8057 else
8058 {
8059 fall = jumping = 0;
8060 if(itemsbuf[itemid].misc1)
8061 hoverclk = itemsbuf[itemid].misc1;
8062 else
8063 {
8064 hoverclk = 1;
8065 hoverflags |= HOV_INF;
8066 }
8067
8068
8069 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8070 }
8071 if(itemsbuf[itemid].wpn)
8072 decorations.add(new dHover(x, y, dHOVER, 0));
8073 }
8074
4/8
✓ Branch 0 taken 118579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118579 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118579 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 118579 times.
118579 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8075 {
8076 118579 fall += gravity3;
8077
8078 118579 }
8079 118579 }
8080 257641 }
8081 else // Topdown gravity
8082 {
8083
4/4
✓ Branch 0 taken 6723132 times.
✓ Branch 1 taken 3371324 times.
✓ Branch 2 taken 3370476 times.
✓ Branch 3 taken 848 times.
10094456 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8084
4/4
✓ Branch 0 taken 6723132 times.
✓ Branch 1 taken 3371324 times.
✓ Branch 2 taken 3370476 times.
✓ Branch 3 taken 848 times.
10094456 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8085
4/4
✓ Branch 0 taken 3368056 times.
✓ Branch 1 taken 6726400 times.
✓ Branch 2 taken 6729668 times.
✓ Branch 3 taken 10097724 times.
10094456 if(z>0||fakez>0)
8086 {
8087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13456068 switch(action)
8088 {
8089 case swimming:
8090 {
8091 diveclk=0;
8092 action=walking; FFCore.setHeroAction(walking);
8093
8094 break;
8095 }
8096 case waterhold1:
8097 {
8098 action=landhold1; FFCore.setHeroAction(landhold1);
8099 break;
8100 }
8101
8102 case waterhold2:
8103 {
8104 action=landhold2; FFCore.setHeroAction(landhold2);
8105 break;
8106 }
8107
8108 default:
8109 3268 break;
8110 }
8111 3268 }
8112
8113
2/2
✓ Branch 0 taken 2813 times.
✓ Branch 1 taken 10100992 times.
10103805 for(int32_t j=0; j<chainlinks.Count(); j++)
8114 {
8115 2813 chainlinks.spr(j)->z=z;
8116 2813 chainlinks.spr(j)->fakez=fakez;
8117 2813 }
8118
8119
2/2
✓ Branch 0 taken 10100263 times.
✓ Branch 1 taken 729 times.
10100992 if(Lwpns.idFirst(wHookshot)>-1)
8120 {
8121 729 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8122 729 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8123 729 }
8124
8125
2/2
✓ Branch 0 taken 10100230 times.
✓ Branch 1 taken 762 times.
10100992 if(Lwpns.idFirst(wHSHandle)>-1)
8126 {
8127 762 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8128 762 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8129 762 }
8130
8131
3/4
✓ Branch 0 taken 3368056 times.
✓ Branch 1 taken 6732936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3368056 times.
10100992 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8132 {
8133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3368056 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3368056 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8134 {
8135
2/2
✓ Branch 0 taken 3368028 times.
✓ Branch 1 taken 28 times.
3368056 if(fall > 0)
8136 {
8137
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✓ Branch 7 taken 6 times.
28 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8138 6 sfx(WAV_ZN1SPLASH,x.getInt());
8139
8140 28 stomping = true;
8141 28 }
8142 3368056 }
8143 3368056 z = fall = 0;
8144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3368056 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3368056 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8145 {
8146 3368056 jumping = 0;
8147
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 3367821 times.
3368056 if(check_pitslide(true) == -1)
8148 {
8149 3367821 hoverclk = 0;
8150 3367821 hoverflags = 0;
8151 3367821 }
8152
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
235 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8153 {
8154 if(!--hoverclk)
8155 {
8156 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8157 }
8158 }
8159 3368056 }
8160 3368056 }
8161
3/4
✓ Branch 0 taken 3371324 times.
✓ Branch 1 taken 6729668 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3371324 times.
10100992 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8162 {
8163
3/4
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 3368056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3268 times.
3371324 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8164 {
8165
1/2
✓ Branch 0 taken 3368056 times.
✗ Branch 1 not taken.
3368056 if(fakefall > 0)
8166 {
8167 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8168 sfx(WAV_ZN1SPLASH,x.getInt());
8169
8170 stomping = true;
8171 }
8172 3368056 }
8173 3371324 fakez = fakefall = 0;
8174
3/4
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 3368056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3268 times.
3371324 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8175 {
8176 3368056 jumping = 0;
8177
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 3367821 times.
3368056 if(check_pitslide(true) == -1)
8178 {
8179 3367821 hoverclk = 0;
8180 3367821 hoverflags = 0;
8181 3367821 }
8182
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
235 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8183 {
8184 if(!--hoverclk)
8185 {
8186 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8187 }
8188 }
8189 3368056 }
8190 3371324 }
8191
8/10
✓ Branch 0 taken 3371301 times.
✓ Branch 1 taken 6729691 times.
✓ Branch 2 taken 3371301 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3364834 times.
✓ Branch 5 taken 6467 times.
✓ Branch 6 taken 3368079 times.
✓ Branch 7 taken 3368079 times.
✓ Branch 8 taken 3368079 times.
✗ Branch 9 not taken.
10100992 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8192 {
8193
4/6
✓ Branch 0 taken 2715 times.
✓ Branch 1 taken 530 times.
✓ Branch 2 taken 2715 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2715 times.
6732913 if(fall != 0 || fakefall != 0 || hoverclk>0)
8194 530 jumping++;
8195
8196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3245 times.
3245 if(hoverclk > 0)
8197 {
8198 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8199 {
8200 --hoverclk;
8201 }
8202
8203 if(!hoverclk)
8204 {
8205 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8206 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8207 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8208 }
8209 }
8210
9/16
✓ Branch 0 taken 3057 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 2725 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 2725 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 520 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 520 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 520 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3245 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3245 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8211 {
8212 if(hoverclk < 0)
8213 hoverclk = -hoverclk;
8214 else
8215 {
8216 fall = 0;
8217 fakefall = 0;
8218 int32_t itemid = current_item_id(itype_hoverboots);
8219 if(itemsbuf[itemid].misc1)
8220 hoverclk = itemsbuf[itemid].misc1;
8221 else
8222 {
8223 hoverclk = 1;
8224 hoverflags |= HOV_INF;
8225 }
8226 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8227 }
8228 decorations.add(new dHover(x, y, dHOVER, 0));
8229 }
8230 else
8231 {
8232
3/6
✓ Branch 0 taken 3245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3245 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3245 times.
3245 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8233
3/6
✓ Branch 0 taken 3245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3245 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3245 times.
✗ Branch 5 not taken.
3245 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8234 }
8235 3245 }
8236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3371324 times.
3371324 if (fakez<0) fakez = 0;
8237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3371324 times.
3371324 if (z<0) z = 0;
8238 }
8239
8240
1/2
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
3628965 if(drunkclk)
8241 {
8242 --drunkclk;
8243 }
8244
8245
1/2
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
3628965 if(lstunclock > 0)
8246 {
8247 // also cancel Hero's attack
8248 attackclk = 0;
8249
8250 if( FFCore.getHeroAction() != stunned )
8251 {
8252 tempaction=action; //update so future checks won't do this
8253 //action=freeze; //setting this makes the player invincible while stunned -V
8254 FFCore.setHeroAction(stunned);
8255 }
8256 --lstunclock;
8257 }
8258 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8259 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8260
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3628965 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3628965 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8261 {
8262 action=tempaction; FFCore.setHeroAction(tempaction);
8263 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8264 //action=none; FFCore.setHeroAction(none);
8265 }
8266
8267
1/2
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
3628965 if( lbunnyclock > 0 )
8268 {
8269 --lbunnyclock;
8270 }
8271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3628965 times.
3628965 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8272 {
8273 int32_t itemid = current_item_id(itype_pearl);
8274 if(itemid > -1)
8275 {
8276 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8277 lbunnyclock = 0;
8278 }
8279 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8280 {
8281 lbunnyclock = -1;
8282 }
8283 }
8284
1/2
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
3628965 else if(lbunnyclock == -1) //dmap-caused bunny effect
8285 {
8286 lbunnyclock = 0;
8287 }
8288
8289
12/16
✓ Branch 0 taken 3624541 times.
✓ Branch 1 taken 4424 times.
✓ Branch 2 taken 3119006 times.
✓ Branch 3 taken 505535 times.
✓ Branch 4 taken 3119006 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1206 times.
✓ Branch 7 taken 3117800 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1206 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 3117197 times.
✓ Branch 13 taken 1809 times.
✓ Branch 14 taken 30192 times.
✓ Branch 15 taken 3086411 times.
3628965 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8290
2/2
✓ Branch 0 taken 3116603 times.
✓ Branch 1 taken 594 times.
3117197 && action != gothit)
8291 {
8292
2/3
✓ Branch 0 taken 1371156 times.
✓ Branch 1 taken 1715255 times.
✗ Branch 2 not taken.
3086411 switch(dir)
8293 {
8294 case up:
8295 case down:
8296 1371156 x=(x.getInt()+4)&0xFFF8;
8297 1371156 break;
8298
8299 case left:
8300 case right:
8301 1715255 y=(y.getInt()+4)&0xFFF8;
8302 1715255 break;
8303 }
8304 3086411 }
8305
8306
4/4
✓ Branch 0 taken 76971 times.
✓ Branch 1 taken 3551994 times.
✓ Branch 2 taken 56861 times.
✓ Branch 3 taken 20110 times.
3628965 if((watch==true) && clockclk)
8307 {
8308 20110 --clockclk;
8309
8310
2/2
✓ Branch 0 taken 20054 times.
✓ Branch 1 taken 56 times.
20110 if(!clockclk)
8311 {
8312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(cheat_superman==false)
8313 {
8314 56 setClock(false);
8315 56 }
8316
8317 56 watch=false;
8318
8319
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 56 times.
28728 for(int32_t i=0; i<eMAXGUYS; i++)
8320 {
8321
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28672 times.
28676 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8322 {
8323 4 addenemy(0,0,i,0);
8324 4 }
8325 28672 }
8326 56 }
8327 20110 }
8328
8329
3/4
✓ Branch 0 taken 3628203 times.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3628203 times.
3628965 if(hookshot_frozen || switch_hooked)
8330 {
8331
3/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 729 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
762 if(hookshot_used || switch_hooked)
8332 {
8333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
729 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8334 729 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8335
8336
3/4
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 584 times.
729 if(pull_hero || switch_hooked)
8337 {
8338
2/4
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
145 if(hs_switcher || switch_hooked)
8339 {
8340 hs_fix = false;
8341 if(switchhookclk)
8342 {
8343 --switchhookclk;
8344 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8345 {
8346 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8347 reset_hookshot();
8348 else
8349 {
8350 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8351 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8352
8353 if(hooked_combopos > -1) //Switching combos
8354 {
8355 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8356 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8357 {
8358 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8359 for(int q = max_layer; q > -1; --q)
8360 {
8361 if(!(hooked_layerbits & (1<<q)))
8362 continue; //non-switching layer
8363 mapscr* scr = FFCore.tempScreens[q];
8364 newcombo const& cmb = combobuf[scr->data[targpos]];
8365 int32_t srcfl = scr->sflag[targpos];
8366 newcombo const& comb2 = combobuf[scr->data[plpos]];
8367 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8368 //{Check push status
8369 bool isFakePush = false;
8370 if(cmb.type == cSWITCHHOOK)
8371 {
8372 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8373 isFakePush = true;
8374 }
8375 bool isPush = isFakePush;
8376 if(!isPush) switch(srcfl)
8377 {
8378 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8379 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8380 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8381 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8382 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8383 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8384 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8385 isPush = true;
8386 }
8387 if(!isPush) switch(cmb.flag)
8388 {
8389 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8390 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8391 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8392 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8393 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8394 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8395 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8396 isPush = true;
8397 }
8398 if(srcfl==mfPUSHED) isPush = false;
8399 //}
8400 if(cmb.type == cSWITCHHOOK) //custom flags and such
8401 {
8402 if(cmb.usrflags&cflag3) //Breaks on swap
8403 {
8404 int32_t it = -1;
8405 int32_t thedropset = -1;
8406 if(cmb.usrflags&cflag4) //drop item
8407 {
8408 if(cmb.usrflags&cflag5)
8409 it = cmb.attribytes[2];
8410 else
8411 {
8412 it = select_dropitem(cmb.attribytes[2]);
8413 thedropset = cmb.attribytes[2];
8414 }
8415 }
8416
8417 breakable* br = new breakable(x, y, zfix(0),
8418 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8419 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8420 br->switch_hooked = true;
8421 decorations.add(br);
8422 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8423 hooked_undercombos[q] = -1;
8424
8425 if(cmb.usrflags&cflag6)
8426 {
8427 scr->data[targpos]++;
8428 }
8429 else
8430 {
8431 scr->data[targpos] = scr->undercombo;
8432 scr->cset[targpos] = scr->undercset;
8433 if(cmb.usrflags&cflag2)
8434 scr->sflag[targpos] = 0;
8435 }
8436 }
8437 else if(isPush)
8438 {
8439 //Simulate a block clicking into place
8440 movingblock mtemp;
8441 mtemp.clear();
8442 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8443 mtemp.dir = getPushDir(scr->sflag[targpos]);
8444 if(mtemp.dir < 0)
8445 mtemp.dir = getPushDir(cmb.flag);
8446 mtemp.clk = 1;
8447 if(isFakePush)
8448 mtemp.force_many = true;
8449 mtemp.animate(0);
8450 if((mtemp.bhole || mtemp.trigger)
8451 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8452 || comb2.flag == mfBLOCKTRIGGER
8453 || comb2.flag == mfBLOCKHOLE))
8454 {
8455 scr->data[targpos] = scr->undercombo;
8456 scr->cset[targpos] = scr->undercset;
8457 scr->sflag[targpos] = 0;
8458 }
8459 else
8460 {
8461 scr->data[targpos] = c;
8462 scr->cset[targpos] = cs;
8463 if(cmb.usrflags&cflag2)
8464 scr->sflag[targpos] = fl;
8465 else
8466 scr->sflag[targpos] = 0;
8467 }
8468 }
8469 else
8470 {
8471 scr->data[plpos] = scr->data[targpos];
8472 scr->cset[plpos] = scr->cset[targpos];
8473 if(cmb.usrflags&cflag2)
8474 scr->sflag[plpos] = scr->sflag[targpos];
8475 scr->data[targpos] = c;
8476 scr->cset[targpos] = cs;
8477 if(cmb.usrflags&cflag2)
8478 scr->sflag[targpos] = fl;
8479 }
8480 }
8481 else if(isCuttableType(cmb.type)) //Break and drop effects
8482 {
8483 int32_t breakcs = scr->cset[targpos];
8484 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8485 {
8486 scr->data[targpos]++;
8487 }
8488 else
8489 {
8490 scr->data[targpos] = scr->undercombo;
8491 scr->cset[targpos] = scr->undercset;
8492 scr->sflag[targpos] = 0;
8493 }
8494
8495 int32_t it = -1;
8496 int32_t thedropset = -1;
8497 if(isCuttableItemType(cmb.type)) //Drop an item
8498 {
8499 if ( (cmb.usrflags&cflag2) )
8500 {
8501 if(cmb.usrflags&cflag11)
8502 it = cmb.attribytes[1];
8503 else
8504 {
8505 it = select_dropitem(cmb.attribytes[1]);
8506 thedropset = cmb.attribytes[1];
8507 }
8508 }
8509 else
8510 {
8511 it = select_dropitem(12);
8512 thedropset = 12;
8513 }
8514 }
8515
8516 byte breaksfx = 0;
8517 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8518 {
8519 if (cmb.usrflags&cflag3)
8520 {
8521 breaksfx = cmb.attribytes[2];
8522 }
8523 else if(isBushType(cmb.type)
8524 || isFlowersType(cmb.type)
8525 || isGrassType(cmb.type))
8526 {
8527 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8528 }
8529 }
8530
8531 //Clipping sprite
8532 int16_t decotype = (cmb.usrflags & cflag1) ?
8533 ((cmb.usrflags & cflag10)
8534 ? (cmb.attribytes[0])
8535 : (-1))
8536 : (0);
8537 if(decotype > 3) decotype = 0;
8538 if(!decotype)
8539 decotype = (isBushType(cmb.type) ? 1
8540 : (isFlowersType(cmb.type) ? 2
8541 : (isGrassType(cmb.type) ? 3
8542 : ((cmb.usrflags & cflag1) ? -1
8543 : -2))));
8544
8545 breakable* br = new breakable(x, y, zfix(0),
8546 cmb, breakcs, it, thedropset, breaksfx,
8547 decotype, cmb.attribytes[0], switchhookclk);
8548 br->switch_hooked = true;
8549 decorations.add(br);
8550 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8551 hooked_undercombos[q] = -1;
8552 }
8553 else //Unknown type, just swap combos.
8554 {
8555 if(isPush)
8556 {
8557 //Simulate a block clicking into place
8558 movingblock mtemp;
8559 mtemp.clear();
8560 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8561 mtemp.dir = getPushDir(scr->sflag[targpos]);
8562 if(mtemp.dir < 0)
8563 mtemp.dir = getPushDir(cmb.flag);
8564 mtemp.clk = 1;
8565 mtemp.animate(0);
8566 if(mtemp.bhole || mtemp.trigger)
8567 {
8568 scr->data[targpos] = scr->undercombo;
8569 scr->cset[targpos] = scr->undercset;
8570 scr->sflag[targpos] = 0;
8571 }
8572 else
8573 {
8574 scr->data[targpos] = c;
8575 scr->cset[targpos] = cs;
8576 scr->sflag[targpos] = 0;
8577 }
8578 }
8579 else
8580 {
8581 scr->data[plpos] = scr->data[targpos];
8582 scr->cset[plpos] = scr->cset[targpos];
8583 scr->data[targpos] = c;
8584 scr->cset[targpos] = cs;
8585 }
8586 }
8587 }
8588 if(switchhook_cost_item > -1)
8589 paymagiccost(switchhook_cost_item);
8590 zfix tx = x, ty = y;
8591 //Position the player at the combo
8592 x = COMBOX(targpos);
8593 y = COMBOY(targpos);
8594 dir = oppositeDir[dir];
8595 if(w && hw)
8596 {
8597 //Calculate chain shift
8598 zfix dx = (x-tx);
8599 zfix dy = (y-ty);
8600 if(w->dir < 4)
8601 {
8602 if(w->dir & 2)
8603 dx = 0;
8604 else dy = 0;
8605 }
8606 //Position the hook head at the handle
8607 w->x = hw->x + dx;
8608 w->y = hw->y + dy;
8609 w->dir = oppositeDir[w->dir];
8610 w->doAutoRotate(true);
8611 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8612 w->flip ^= hflip;
8613 //Position the handle appropriately
8614 hw->x = x-(hw->x-tx);
8615 hw->y = y-(hw->y-ty);
8616 hw->dir = oppositeDir[hw->dir];
8617 hw->doAutoRotate(true);
8618 hw->flip ^= hflip;
8619 //Move chains
8620 for(int32_t j=0; j<chainlinks.Count(); j++)
8621 {
8622 chainlinks.spr(j)->x += dx;
8623 chainlinks.spr(j)->y += dy;
8624 }
8625 }
8626 hooked_combopos = plpos; //flip positions
8627 }
8628 else reset_hookshot();
8629 }
8630 else if(switching_object) //Switching an object
8631 {
8632 if(switchhook_cost_item > -1)
8633 paymagiccost(switchhook_cost_item);
8634 zfix tx = x, ty = y;
8635 //Position the player at the object
8636 x = switching_object->x;
8637 y = switching_object->y;
8638 dir = oppositeDir[dir];
8639 //Position the object at the player
8640 switching_object->x = tx;
8641 switching_object->y = ty;
8642 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8643 switching_object->dir = oppositeDir[switching_object->dir];
8644 solid_update(false);
8645 switching_object->solid_update(false);
8646 if(item* it = dynamic_cast<item*>(switching_object))
8647 {
8648 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8649 {
8650 movefairynew2(it->x, it->y, *it);
8651 }
8652 }
8653 if(w && hw) //!TODO No fucking clue if diagonals work
8654 {
8655 //Calculate chain shift
8656 zfix dx = (x-tx);
8657 zfix dy = (y-ty);
8658 if(w->dir < 4)
8659 {
8660 if(w->dir & 2)
8661 dx = 0;
8662 else dy = 0;
8663 }
8664 //Position the hook head at the handle
8665 w->x = hw->x + dx;
8666 w->y = hw->y + dy;
8667 w->dir = oppositeDir[w->dir];
8668 w->doAutoRotate(true);
8669 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8670 w->flip ^= hflip;
8671 w->solid_update(false);
8672 //Position the handle appropriately
8673 hw->x = x-(hw->x-tx);
8674 hw->y = y-(hw->y-ty);
8675 hw->dir = oppositeDir[hw->dir];
8676 hw->doAutoRotate(true);
8677 hw->flip ^= hflip;
8678 hw->solid_update(false);
8679 //Move chains
8680 for(int32_t j=0; j<chainlinks.Count(); j++)
8681 {
8682 chainlinks.spr(j)->x += dx;
8683 chainlinks.spr(j)->y += dy;
8684 }
8685 }
8686 }
8687 }
8688 }
8689 else if(!switchhookclk)
8690 {
8691 reset_hookshot();
8692 }
8693 }
8694 else reset_hookshot();
8695 }
8696 else
8697 {
8698 sprite *t;
8699 int32_t i;
8700
8701
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
145 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8702 {
8703 /* do nothing */
8704 }
8705
8706 145 t = Lwpns.spr(i);
8707
8708
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 145 times.
435 for(i=0; i<Lwpns.Count(); i++)
8709 {
8710 290 sprite *s = Lwpns.spr(i);
8711
8712
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 145 times.
290 if(s->id==wHookshot)
8713 {
8714
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 124 times.
145 if (abs((s->y) - y) >= 1)
8715 {
8716
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 10 times.
21 if((s->y)>y)
8717 {
8718 10 y+=4;
8719
8720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Lwpns.idFirst(wHSHandle)!=-1)
8721 {
8722 10 t->y+=4;
8723 10 }
8724
8725 10 hs_starty+=4;
8726 10 }
8727
8728
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11 times.
21 if((s->y)<y)
8729 {
8730 11 y-=4;
8731
8732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Lwpns.idFirst(wHSHandle)!=-1)
8733 {
8734 11 t->y-=4;
8735 11 }
8736
8737 11 hs_starty-=4;
8738 11 }
8739 21 }
8740 else
8741 {
8742 124 y = (s->y);
8743 }
8744
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 21 times.
145 if (abs((s->x) - x) >= 1)
8745 {
8746
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 107 times.
124 if((s->x)>x)
8747 {
8748 107 x+=4;
8749
8750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(Lwpns.idFirst(wHSHandle)!=-1)
8751 {
8752 107 t->x+=4;
8753 107 }
8754
8755 107 hs_startx+=4;
8756 107 }
8757
8758
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 17 times.
124 if((s->x)<x)
8759 {
8760 17 x-=4;
8761
8762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(Lwpns.idFirst(wHSHandle)!=-1)
8763 {
8764 17 t->x-=4;
8765 17 }
8766
8767 17 hs_startx-=4;
8768 17 }
8769 124 }
8770 else
8771 {
8772 21 x = (s->x);
8773 }
8774 145 }
8775 290 }
8776 }
8777 145 }
8778 729 }
8779 else
8780 {
8781 33 Lwpns.del(Lwpns.idFirst(wHSHandle));
8782 33 reset_hookshot();
8783 }
8784
8785
1/2
✓ Branch 0 taken 762 times.
✗ Branch 1 not taken.
762 if(hs_fix)
8786 {
8787 if(dir==up)
8788 {
8789 y=int32_t(y+7)&0xF0;
8790 }
8791
8792 if(dir==down)
8793 {
8794 y=int32_t(y+7)&0xF0;
8795 }
8796
8797 if(dir==left)
8798 {
8799 x=int32_t(x+7)&0xF0;
8800 }
8801
8802 if(dir==right)
8803 {
8804 x=int32_t(x+7)&0xF0;
8805 }
8806
8807 hs_fix=false;
8808 }
8809
8810 762 }
8811
8812
2/2
✓ Branch 0 taken 319621 times.
✓ Branch 1 taken 3309344 times.
3628965 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8813 {
8814
2/2
✓ Branch 0 taken 1817 times.
✓ Branch 1 taken 3307527 times.
3309344 if(DrunkrLbtn())
8815 1817 selectNextBWpn(SEL_LEFT);
8816
2/2
✓ Branch 0 taken 3305541 times.
✓ Branch 1 taken 1986 times.
3307527 else if(DrunkrRbtn())
8817 1986 selectNextBWpn(SEL_RIGHT);
8818 3309344 }
8819
4/4
✓ Branch 0 taken 319621 times.
✓ Branch 1 taken 3309344 times.
✓ Branch 2 taken 319057 times.
✓ Branch 3 taken 564 times.
3628965 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8820 {
8821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 564 times.
564 if (rEx3btn())
8822 selectNextAWpn(SEL_LEFT);
8823
2/2
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 1 times.
564 else if (rEx4btn())
8824 1 selectNextAWpn(SEL_RIGHT);
8825 564 }
8826
8827
2/2
✓ Branch 0 taken 3628904 times.
✓ Branch 1 taken 61 times.
3628965 if(rPbtn())
8828 {
8829
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 58 times.
61 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8830 58 onViewMap();
8831 61 }
8832
2/2
✓ Branch 0 taken 2000552 times.
✓ Branch 1 taken 3628965 times.
5629517 for(int32_t i=0; i<Lwpns.Count(); i++)
8833 {
8834 2000552 weapon *w = ((weapon*)Lwpns.spr(i));
8835
8836
5/6
✓ Branch 0 taken 1992285 times.
✓ Branch 1 taken 8267 times.
✓ Branch 2 taken 1808431 times.
✓ Branch 3 taken 183854 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1808431 times.
2000552 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8837 192121 addsparkle(i);
8838 2000552 }
8839
8840
1/2
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
3628965 if(Lwpns.idCount(wPhantom))
8841 {
8842 addsparkle2(pDINSFIREROCKET,pDINSFIREROCKETTRAIL);
8843 addsparkle2(pDINSFIREROCKETRETURN,pDINSFIREROCKETTRAILRETURN);
8844 addsparkle2(pNAYRUSLOVEROCKET1,pNAYRUSLOVEROCKETTRAIL1);
8845 addsparkle2(pNAYRUSLOVEROCKET2,pNAYRUSLOVEROCKETTRAIL2);
8846 addsparkle2(pNAYRUSLOVEROCKETRETURN1,pNAYRUSLOVEROCKETTRAILRETURN1);
8847 addsparkle2(pNAYRUSLOVEROCKETRETURN2,pNAYRUSLOVEROCKETTRAILRETURN2);
8848 }
8849
8850 // Pay magic cost for Byrna beams
8851
8852 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8853
1/2
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
3628965 if(Lwpns.idCount(wCByrna))
8854 {
8855 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8856 int32_t itemid = ew->parentitem;
8857
8858 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8859 {
8860 for(int32_t i=0; i<Lwpns.Count(); i++)
8861 {
8862 weapon *w = ((weapon*)Lwpns.spr(i));
8863
8864 if(w->id==wCByrna)
8865 {
8866 w->dead=1;
8867 }
8868
8869 }
8870 //kill the sound effect for the orbits -Z 14FEB2019
8871 stop_sfx(itemsbuf[itemid].usesound);
8872 }
8873 else paymagiccost(itemid);
8874 }
8875
8876
3/4
✓ Branch 0 taken 3625697 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 3625697 times.
✗ Branch 3 not taken.
3628965 if(z==0&&fakez==0)
8877 {
8878 3625697 switchblock_z = 0;
8879
1/2
✓ Branch 0 taken 3625697 times.
✗ Branch 1 not taken.
3625697 if(switchblock_offset)
8880 {
8881 switchblock_offset=false;
8882 yofs += 8;
8883 }
8884 3625697 }
8885
2/2
✓ Branch 0 taken 257641 times.
✓ Branch 1 taken 3371324 times.
3628965 if(!isSideViewHero())
8886 {
8887 3371324 int32_t tx = x.getInt()+8,
8888 3371324 ty = y.getInt()+8;//(bigHitbox?8:12);
8889
4/4
✓ Branch 0 taken 3371194 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 3371089 times.
3371324 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8890 {
8891
2/2
✓ Branch 0 taken 3371089 times.
✓ Branch 1 taken 10113267 times.
13484356 for(int32_t q = 0; q < 3; ++q)
8892 {
8893
4/4
✓ Branch 0 taken 6742178 times.
✓ Branch 1 taken 3371089 times.
✓ Branch 2 taken 1079176 times.
✓ Branch 3 taken 5663002 times.
10113267 if(q && !tmpscr2[q-1].valid) continue;
8894 4450265 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8895
3/4
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 4449315 times.
✓ Branch 2 taken 950 times.
✗ Branch 3 not taken.
4450265 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8896 int32_t b = 1;
8897 if(tx&8) b <<= 2;
8898 if(ty&8) b <<= 1;
8899 b |= (b<<4); //check equivalent effect flag too
8900 if((cmb.walk&b)==b) //solid and effecting
8901 {
8902 if(z==0&&fakez==0)
8903 {
8904 if(cmb.usrflags&cflag10)
8905 {
8906 if(!switchblock_offset)
8907 {
8908 switchblock_offset=true;
8909 yofs -= 8;
8910 }
8911 }
8912 else
8913 {
8914 if(switchblock_offset)
8915 {
8916 switchblock_offset=false;
8917 yofs += 8;
8918 }
8919 }
8920 }
8921 if(cmb.attributes[2]>0 && switchblock_z>=0)
8922 {
8923 if(z==0&&fakez==0)
8924 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8925 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8926 {
8927 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8928 }
8929 }
8930 else switchblock_z = -1;
8931 break;
8932 }
8933 }
8934 3371089 }
8935 3371324 }
8936 3628965 ClearhitHeroUIDs(); //clear them before we advance.
8937 3628965 checkhit();
8938
8939 3628965 bool forcedeath = dying_flags&DYING_FORCED;
8940 3628965 bool norev = (dying_flags&DYING_NOREV);
8941
4/6
✓ Branch 0 taken 3628965 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 3628907 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 58 times.
3628965 if(forcedeath || (game->get_life()<=0 && !immortal))
8942 {
8943
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(forcedeath)
8944 game->set_life(0);
8945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(!norev)
8946
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 14848 times.
14906 for(size_t slot = 0; slot < 256; ++slot)
8947 {
8948
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(size_t bind = game->get_bottle_slot(slot))
8949 {
8950 bottletype const* bt = &QMisc.bottle_types[bind-1];
8951 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8952 continue;
8953 word toFill[3] = { 0 };
8954 for(size_t q = 0; q < 3; ++q)
8955 {
8956 char c = bt->counter[q];
8957 if(c > -1)
8958 {
8959 if(bt->flags & (1<<q))
8960 {
8961 toFill[q] = (bt->amount[q]==100)
8962 ? game->get_maxcounter(c)
8963 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
8964 }
8965 else toFill[q] = bt->amount[q];
8966 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
8967 {
8968 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
8969 }
8970 }
8971 }
8972 if(bt->flags & BTFLAG_CURESWJINX)
8973 {
8974 swordclk = 0;
8975 verifyAWpn();
8976 }
8977 if(bt->flags & BTFLAG_CUREITJINX)
8978 itemclk = 0;
8979 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
8980 {
8981 int32_t itemid = find_bottle_for_slot(slot,true);
8982 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
8983 if(itemid > -1)
8984 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8985 for(size_t q = 0; q < 20; ++q)
8986 do_death_refill_waitframe();
8987 double inc = max/60.0; //1 second
8988 double xtra[3]{ 0 };
8989 for(size_t q = 0; q < 60; ++q)
8990 {
8991 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
8992 sfx(QMisc.miscsfx[sfxREFILL]);
8993 for(size_t j = 0; j < 3; ++j)
8994 {
8995 xtra[j] += inc;
8996 word f = floor(xtra[j]);
8997 xtra[j] -= f;
8998 if(toFill[j] > f)
8999 {
9000 toFill[j] -= f;
9001 game->change_counter(f,bt->counter[j]);
9002 }
9003 else if(toFill[j])
9004 {
9005 game->change_counter(toFill[j],bt->counter[j]);
9006 toFill[j] = 0;
9007 }
9008 }
9009 do_death_refill_waitframe();
9010 }
9011 for(size_t j = 0; j < 3; ++j)
9012 {
9013 if(toFill[j])
9014 {
9015 game->change_counter(toFill[j],bt->counter[j]);
9016 toFill[j] = 0;
9017 }
9018 }
9019 for(size_t q = 0; q < 20; ++q)
9020 do_death_refill_waitframe();
9021 }
9022 game->set_bottle_slot(slot,bt->next_type);
9023 if(game->get_life() > 0)
9024 {
9025 dying_flags = 0;
9026 forcedeath = false;
9027 break; //Revived! Stop drinking things...
9028 }
9029 }
9030 14906 }
9031
9032
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 46 times.
58 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9033 {
9034
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
12 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9035 {
9036 // So scripts can have one frame to handle hp zero events
9037
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
12 if(norev || false == (last_hurrah = !last_hurrah))
9038 {
9039 1 dying_flags = 0;
9040 1 drunkclk=0;
9041 1 lstunclock = 0;
9042 1 is_conveyor_stunned = 0;
9043 1 FFCore.setHeroAction(dying);
9044 1 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
9045 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
9046 1 ALLOFF(true,true);
9047 1 GameFlags |= GAMEFLAG_NO_F6;
9048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!debug_enabled)
9049 {
9050 1 Paused=false;
9051 1 }
9052
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9053 {
9054 FFCore.runOnDeathEngine();
9055 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9056 }
9057 1 Playing = false;
9058 1 heroDeathAnimation();
9059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9060 {
9061 1 Playing = true;
9062 1 FFCore.runOnDeathEngine();
9063 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9064 1 Playing = false;
9065 1 }
9066 1 GameFlags &= ~GAMEFLAG_NO_F6;
9067 1 ALLOFF(true,true);
9068 1 return true;
9069 }
9070 11 }
9071 11 }
9072 else //2.50.x
9073 {
9074 // So scripts can have one frame to handle hp zero events
9075
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 23 times.
46 if(false == (last_hurrah = !last_hurrah))
9076 {
9077 23 drunkclk=0;
9078 23 heroDeathAnimation();
9079
9080 23 return true;
9081 }
9082 }
9083 34 }
9084 3628907 else last_hurrah=false;
9085
9086
2/2
✓ Branch 0 taken 20099 times.
✓ Branch 1 taken 3608842 times.
3628941 if(swordclk>0)
9087 {
9088 20099 --swordclk;
9089
2/2
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 98 times.
20099 if(!swordclk) verifyAWpn();
9090 20099 }
9091
2/2
✓ Branch 0 taken 4058 times.
✓ Branch 1 taken 3624883 times.
3628941 if(itemclk>0)
9092 4058 --itemclk;
9093
9094
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 3628649 times.
3628941 if(inwallm)
9095 {
9096 292 attackclk=0;
9097 292 herostep();
9098
9099
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(CarryHero()==false)
9100 3 restart_level();
9101
9102 292 solid_update(false);
9103 292 return false;
9104 }
9105
9106
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3628648 times.
3628649 if(ewind_restart)
9107 {
9108 1 attackclk=0;
9109 1 restart_level();
9110 1 xofs=0;
9111 1 action=none; FFCore.setHeroAction(none);
9112 1 ewind_restart=false;
9113 1 solid_update(false);
9114 1 return false;
9115 }
9116
9117
2/2
✓ Branch 0 taken 3626193 times.
✓ Branch 1 taken 2455 times.
3628648 if(hopclk)
9118 {
9119 2455 action=hopping; FFCore.setHeroAction(hopping);
9120 2455 }
9121
2/2
✓ Branch 0 taken 3628438 times.
✓ Branch 1 taken 210 times.
3628648 if(fallclk)
9122 {
9123 210 action=falling; FFCore.setHeroAction(falling);
9124 210 }
9125
9126 3628648 handle_passive_buttons();
9127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3628648 times.
3628648 if(liftclk)
9128 {
9129 if(lift_wpn)
9130 {
9131 action=lifting; FFCore.setHeroAction(lifting);
9132 }
9133 else
9134 {
9135 liftclk = 0;
9136 tliftclk = 0;
9137 }
9138 }
9139
1/2
✓ Branch 0 taken 3628648 times.
✗ Branch 1 not taken.
3628648 else if(lift_wpn)
9140 {
9141 handle_lift(false);
9142 }
9143
9144
9145 // get user input or do other animation
9146 3628648 freeze_guys=false; // reset this flag, set it again if holding
9147
9148
14/16
✓ Branch 0 taken 3599406 times.
✓ Branch 1 taken 29242 times.
✓ Branch 2 taken 3590302 times.
✓ Branch 3 taken 9104 times.
✓ Branch 4 taken 3589912 times.
✓ Branch 5 taken 390 times.
✓ Branch 6 taken 3589782 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 3589782 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3589782 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3578231 times.
✓ Branch 13 taken 11551 times.
✓ Branch 14 taken 21 times.
✓ Branch 15 taken 3578210 times.
3628648 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9149 {
9150 21 holdclk=0;
9151 21 }
9152
9153 3628648 active_shield_id = refreshActiveShield();
9154 3628648 bool sh = active_shield_id > -1;
9155 3628648 itemdata const& shield = itemsbuf[active_shield_id];
9156 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9157 3628648 shield_forcedir = -1;
9158
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3628648 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3628648 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9159 {
9160 shield_forcedir = dir;
9161 }
9162
1/2
✓ Branch 0 taken 3628648 times.
✗ Branch 1 not taken.
3628648 if(sh != shield_active) //Toggle active shield on/off
9163 {
9164 shield_active = sh;
9165 if(sh) //Toggle active shield on
9166 {
9167 sfx(shield.usesound2); //'Activate' sfx
9168 }
9169 }
9170
9171 3628648 bool isthissolid = false;
9172
10/12
✓ Branch 0 taken 21228 times.
✓ Branch 1 taken 520 times.
✓ Branch 2 taken 704 times.
✓ Branch 3 taken 48085 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38346 times.
✓ Branch 6 taken 3481962 times.
✓ Branch 7 taken 32167 times.
✓ Branch 8 taken 210 times.
✓ Branch 9 taken 2455 times.
✓ Branch 10 taken 2971 times.
✗ Branch 11 not taken.
3628648 switch(action)
9173 {
9174 case gothit:
9175
2/2
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 31166 times.
32167 if(attackclk)
9176
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 122 times.
1123 if(!doattack())
9177 {
9178 122 attackclk=spins=0;
9179 122 tapping=false;
9180 122 }
9181
9182 32167 break;
9183
9184 case drowning:
9185 case lavadrowning:
9186 case sidedrowning:
9187 {
9188 704 herostep(); // maybe this line should be elsewhere?
9189
9190 //!DROWN
9191 // Helpful comment to find drowning -Dimi
9192
9193 704 drop_liftwpn();
9194
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 11 times.
704 if(--drownclk==0)
9195 {
9196 11 action=none; FFCore.setHeroAction(none);
9197 11 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9198 11 int32_t damage = combobuf[water].attributes[0]/10000L;
9199 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9200 11 drownCombo = 0;
9201
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (combobuf[water].type != cWATER) damage = 4;
9202 11 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9203 11 go_respawn_point();
9204 11 hclk=48;
9205 11 }
9206
9207 704 break;
9208 }
9209 case falling:
9210 {
9211 210 herostep();
9212 210 pitfall();
9213 210 break;
9214 }
9215 case freeze:
9216 case sideswimfreeze:
9217 case scrolling:
9218 48085 break;
9219
9220 case casting:
9221 case sideswimcasting:
9222 {
9223 if(magicitem==-1)
9224 {
9225 action=none; FFCore.setHeroAction(none);
9226 }
9227
9228 break;
9229 }
9230 case landhold1:
9231 case landhold2:
9232 {
9233
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 38051 times.
38346 if(--holdclk <= 0)
9234 {
9235 //restart music
9236
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 232 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 28 times.
295 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9237 28 playLevelMusic();
9238
9239 295 action=none; FFCore.setHeroAction(none);
9240 295 }
9241 else
9242 38051 freeze_guys=true;
9243
9244 38346 break;
9245 }
9246 case waterhold1:
9247 case waterhold2:
9248 case sidewaterhold1:
9249 case sidewaterhold2:
9250 {
9251 520 diveclk=0;
9252
9253
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 516 times.
520 if(--holdclk <= 0)
9254 {
9255 //restart music
9256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9257 playLevelMusic();
9258
9259 4 SetSwim();
9260 4 }
9261 else
9262 516 freeze_guys=true;
9263
9264 520 break;
9265 }
9266 case hopping:
9267 {
9268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2455 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2455 if(DRIEDLAKE)
9269 {
9270 action=none; FFCore.setHeroAction(none);
9271 hopclk = 0;
9272 diveclk = 0;
9273 break;
9274 }
9275
9276 2455 do_hopping();
9277 2455 break;
9278 }
9279 case inwind:
9280 {
9281 2971 int32_t i=Lwpns.idFirst(wWind);
9282
9283
2/2
✓ Branch 0 taken 2930 times.
✓ Branch 1 taken 41 times.
2971 if(i<0)
9284 {
9285 41 bool exit=false;
9286
9287
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 21 times.
41 if(whirlwind==255)
9288 {
9289 20 exit=true;
9290 20 }
9291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(y<=0 && dir==up) y=-1;
9292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(y>=160 && dir==down) y=161;
9293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(x<=0 && dir==left) x=-1;
9294
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 else if(x>=240 && dir==right) x=241;
9295 else exit=true;
9296
9297
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 if(exit)
9298 {
9299 20 action=none; FFCore.setHeroAction(none);
9300 20 xofs=0;
9301 20 whirlwind=0;
9302 20 lstep=0;
9303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if ( dontdraw < 2 ) dontdraw=0;
9304 20 set_respawn_point();
9305 20 }
9306 41 }
9307 /*
9308 else if (((weapon*)Lwpns.spr(i))->dead==1)
9309 {
9310 whirlwind=255;
9311 }
9312 */
9313 else
9314 {
9315 2930 x=Lwpns.spr(i)->x;
9316 2930 y=Lwpns.spr(i)->y;
9317 2930 dir=Lwpns.spr(i)->dir;
9318 }
9319 }
9320 2971 break;
9321 case lifting:
9322 handle_lift();
9323 break;
9324
9325 case sideswimming:
9326 case sideswimattacking:
9327 case sideswimhit:
9328 case swimhit:
9329 case swimming:
9330 {
9331
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21228 if(DRIEDLAKE)
9332 {
9333 action=none; FFCore.setHeroAction(none);
9334 hopclk=0;
9335 break;
9336 }
9337
9338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21228 times.
21228 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9339
9340
4/4
✓ Branch 0 taken 10599 times.
✓ Branch 1 taken 10629 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 10510 times.
21228 if((frame&1) && !shouldbreak)
9341 10510 herostep();
9342
9343
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21228 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21228 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 19516 times.
22940 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9344
4/6
✓ Branch 0 taken 19516 times.
✓ Branch 1 taken 1712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1712 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1712 times.
21228 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9345
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1712 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1712 times.
1712 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9346
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1712 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1712 times.
21228 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9347
4/4
✓ Branch 0 taken 19961 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 19961 times.
✓ Branch 3 taken 1267 times.
21228 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9348 {
9349
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1255 times.
✓ Branch 3 taken 1 times.
2523 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9350
4/4
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1256 times.
✓ Branch 3 taken 6 times.
1264 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9351 {
9352 12 hopclk=0;
9353 12 diveclk=0;
9354
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9355 else {action=attacking; FFCore.setHeroAction(attacking);}
9356 12 hopdir=-1;
9357 12 }
9358 1267 }
9359
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 21041 times.
21228 if (shouldbreak) break;
9360
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 21029 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
21041 if (action == swimming || action == sideswimming || action == sideswimattacking)
9361 {
9362 21029 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21029 times.
21029 if (combobuf[watercheck].usrflags&cflag2)
9364 {
9365 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9366 {
9367 onpassivedmg = true;
9368 if (damageovertimeclk == 0)
9369 {
9370 int32_t curhp = game->get_life();
9371 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9372 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9373 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9374 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9375 {
9376 hclk = 48;
9377 hitdir = -1;
9378 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9379 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9380 }
9381 }
9382 if (combobuf[watercheck].attribytes[1] > 0)
9383 {
9384 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9385 else --damageovertimeclk;
9386 }
9387 else damageovertimeclk = 0;
9388 }
9389 else damageovertimeclk = 0;
9390 }
9391 21029 else damageovertimeclk = 0;
9392 //combobuf[watercheck].attributes[0]
9393 21029 }
9394
9395 21041 }
9396 [[fallthrough]];
9397 default:
9398 3503003 movehero(); // call the main movement routine
9399 3503003 }
9400
9401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3628648 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3628648 if(shield_forcedir > -1 && action != rafting)
9402 dir = shield_forcedir;
9403
9404
2/2
✓ Branch 0 taken 3614410 times.
✓ Branch 1 taken 14238 times.
3628648 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9405 14238 set_respawn_point(false); //Keep the 'last safe location' updated!
9406
9407 // check for ladder removal
9408
2/2
✓ Branch 0 taken 505551 times.
✓ Branch 1 taken 3123097 times.
3628648 if(diagonalMovement)
9409 {
9410
2/2
✓ Branch 0 taken 505528 times.
✓ Branch 1 taken 23 times.
505551 if(ladderx+laddery)
9411 {
9412
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(ladderdir==up)
9413 {
9414 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9415 {
9416 reset_ladder();
9417 }
9418 }
9419 else
9420 {
9421
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 22 times.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 22 times.
23 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9422 {
9423 1 reset_ladder();
9424 1 }
9425 }
9426 23 }
9427 505551 }
9428 else
9429 {
9430
4/4
✓ Branch 0 taken 102004 times.
✓ Branch 1 taken 3021093 times.
✓ Branch 2 taken 47043 times.
✓ Branch 3 taken 54961 times.
3123097 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9431 {
9432 3068136 reset_ladder();
9433 3068136 }
9434 }
9435
9436
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 3628267 times.
3628648 if(ilswim)
9437 381 landswim++;
9438 3628267 else landswim=0;
9439
9440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3628648 times.
3628648 if(hopclk!=0xFF) ilswim=false;
9441
9442
3/4
✓ Branch 0 taken 6892 times.
✓ Branch 1 taken 3621756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6892 times.
3628648 if((!loaded_guys) && (frame - newscr_clk >= 1))
9443 {
9444
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 6887 times.
6892 if(tmpscr->room==rGANON)
9445 {
9446 5 ganon_intro();
9447 5 }
9448 else
9449 {
9450 6887 loadguys();
9451 }
9452 6892 }
9453
9454
2/2
✓ Branch 0 taken 7223 times.
✓ Branch 1 taken 3621425 times.
3628648 if(frame - newscr_clk >= 2)
9455 {
9456 3621425 loadenemies();
9457 3621425 }
9458
9459 // check lots of other things
9460 3628648 checkscroll();
9461
9462
6/8
✓ Branch 0 taken 3625698 times.
✓ Branch 1 taken 2950 times.
✓ Branch 2 taken 3625005 times.
✓ Branch 3 taken 693 times.
✓ Branch 4 taken 3625005 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3625005 times.
3628648 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9463 {
9464 3625005 checkspecial();
9465 3625005 checkitems();
9466 3625005 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9467
2/2
✓ Branch 0 taken 14676 times.
✓ Branch 1 taken 3610329 times.
3625005 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9468 {
9469 3610329 oldchecklockblock();
9470 3610329 oldcheckbosslockblock();
9471 3610329 }
9472
2/2
✓ Branch 0 taken 144343 times.
✓ Branch 1 taken 3480662 times.
3625005 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9473 {
9474 3480662 oldcheckchest(cCHEST);
9475 3480662 oldcheckchest(cLOCKEDCHEST);
9476 3480662 oldcheckchest(cBOSSCHEST);
9477 3480662 }
9478 3625005 checkpushblock();
9479 3625005 checkswordtap();
9480
9481
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 3624243 times.
3625005 if(hookshot_frozen==false)
9482 {
9483 3624243 checkspecial2(&lsave);
9484 3624243 }
9485
9486
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3625001 times.
3625005 if(action==won)
9487 {
9488 4 return true;
9489 }
9490 3625001 }
9491
9492 // Somehow Hero was displaced from the fairy flag...
9493
3/6
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 3617093 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11551 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3628644 if(fairyclk && action != freeze && action != sideswimfreeze)
9494 {
9495 fairyclk = holdclk = refill_why = 0;
9496 }
9497
9498
3/4
✓ Branch 0 taken 3628644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3626960 times.
✓ Branch 3 taken 1684 times.
3628644 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9499 {
9500 1684 tmpscr->timedwarptics--;
9501
9502
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 7 times.
1684 if(tmpscr->timedwarptics==0)
9503 {
9504 7 activated_timed_warp=true;
9505
9506
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(tmpscr->flags4 & fTIMEDDIRECT)
9507 {
9508 3 didpit=true;
9509 3 pitx=x;
9510 3 pity=y;
9511 3 }
9512
9513 7 int32_t index2 = 0;
9514
9515
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9516
9517 7 sdir = dir;
9518 7 dowarp(1,index2);
9519 7 }
9520 1684 }
9521
9522 3628644 bool awarp = false;
9523 //!DIMI: Global Combo Effects (AUTO STUFF)
9524
2/2
✓ Branch 0 taken 128047 times.
✓ Branch 1 taken 3628644 times.
3756691 for(auto& p : slopes)
9525 {
9526 128047 slope_object& s = p.second;
9527 128047 s.updateslope(); //sets old x/y poses
9528 }
9529
2/2
✓ Branch 0 taken 3628643 times.
✓ Branch 1 taken 638641318 times.
642269961 for(int32_t i=0; i<176; ++i)
9530 {
9531
2/2
✓ Branch 0 taken 2462768 times.
✓ Branch 1 taken 2561953573 times.
2564416341 for(int32_t layer=0; layer<7; ++layer)
9532 {
9533
2/2
✓ Branch 0 taken 1923312255 times.
✓ Branch 1 taken 638641318 times.
2561953573 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9534 2561953573 newcombo const& cmb = combobuf[cid];
9535
9536
2/2
✓ Branch 0 taken 17239376 times.
✓ Branch 1 taken 2544714197 times.
2561953573 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9537 {
9538
2/2
✓ Branch 0 taken 636178549 times.
✓ Branch 1 taken 1908535648 times.
2544714197 if(layer > 2) break;
9539
4/4
✓ Branch 0 taken 636178549 times.
✓ Branch 1 taken 1272357099 times.
✓ Branch 2 taken 613126069 times.
✓ Branch 3 taken 23052480 times.
1908535648 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9540
4/4
✓ Branch 0 taken 636178549 times.
✓ Branch 1 taken 659231030 times.
✓ Branch 2 taken 23052480 times.
✓ Branch 3 taken 613126069 times.
1295409579 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9541 682283510 }
9542 699522886 int32_t ind=0;
9543
9544 //AUTOMATIC TRIGGER CODE
9545
1/2
✓ Branch 0 taken 699522886 times.
✗ Branch 1 not taken.
699522886 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9546 {
9547 do_trigger_combo(layer, i);
9548 }
9549
9550 //AUTO WARP CODE
9551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 699522886 times.
699522886 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9552 {
9553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 699522886 times.
699522886 if(cmb.type==cAWARPA)
9554 {
9555 awarp=true;
9556 ind=0;
9557 }
9558
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 699522885 times.
699522886 else if(cmb.type==cAWARPB)
9559 {
9560 1 awarp=true;
9561 1 ind=1;
9562 1 }
9563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 699522885 times.
699522885 else if(cmb.type==cAWARPC)
9564 {
9565 awarp=true;
9566 ind=2;
9567 }
9568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 699522885 times.
699522885 else if(cmb.type==cAWARPD)
9569 {
9570 awarp=true;
9571 ind=3;
9572 }
9573
1/2
✓ Branch 0 taken 699522885 times.
✗ Branch 1 not taken.
699522885 else if(cmb.type==cAWARPR)
9574 {
9575 awarp=true;
9576 ind=zc_oldrand()%4;
9577 }
9578 699522886 }
9579
2/2
✓ Branch 0 taken 699522885 times.
✓ Branch 1 taken 1 times.
699522886 if(awarp)
9580 {
9581
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTAWARP)
9582 {
9583 didpit=true;
9584 pitx=x;
9585 pity=y;
9586 }
9587
9588 1 sdir = dir;
9589 1 dowarp(1,ind);
9590 1 break;
9591 }
9592 699522885 }
9593
2/2
✓ Branch 0 taken 638641317 times.
✓ Branch 1 taken 1 times.
638641318 if(awarp) break;
9594 638641317 }
9595
9596 3628644 awarp=false;
9597
9598 3628644 word c = tmpscr->numFFC();
9599
2/2
✓ Branch 0 taken 3628638 times.
✓ Branch 1 taken 112291463 times.
115920101 for(word i=0; i<c; i++)
9600 {
9601 112291463 int32_t ind=0;
9602
9603 112291463 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9604
9605
1/2
✓ Branch 0 taken 112291463 times.
✗ Branch 1 not taken.
112291463 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9606 {
9607 do_trigger_combo_ffc(i);
9608 }
9609
9610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112291463 times.
112291463 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9611 {
9612
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 112291460 times.
112291463 if(cmb.type==cAWARPA)
9613 {
9614 3 awarp=true;
9615 3 ind=0;
9616 3 }
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112291460 times.
112291460 else if(cmb.type==cAWARPB)
9618 {
9619 awarp=true;
9620 ind=1;
9621 }
9622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112291460 times.
112291460 else if(cmb.type==cAWARPC)
9623 {
9624 awarp=true;
9625 ind=2;
9626 }
9627
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 112291457 times.
112291460 else if(cmb.type==cAWARPD)
9628 {
9629 3 awarp=true;
9630 3 ind=3;
9631 3 }
9632
1/2
✓ Branch 0 taken 112291457 times.
✗ Branch 1 not taken.
112291457 else if(cmb.type==cAWARPR)
9633 {
9634 awarp=true;
9635 ind=zc_oldrand()%4;
9636 }
9637 112291463 }
9638
9639
2/2
✓ Branch 0 taken 112291457 times.
✓ Branch 1 taken 6 times.
112291463 if(awarp)
9640 {
9641
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(tmpscr->flags5&fDIRECTAWARP)
9642 {
9643 didpit=true;
9644 pitx=x;
9645 pity=y;
9646 }
9647
9648 6 sdir = dir;
9649 6 dowarp(1,ind);
9650 6 break;
9651 }
9652 112291457 }
9653 3628644 zfix dx, dy;
9654
7/8
✓ Branch 0 taken 257633 times.
✓ Branch 1 taken 3371011 times.
✓ Branch 2 taken 129099 times.
✓ Branch 3 taken 128534 times.
✓ Branch 4 taken 2082 times.
✓ Branch 5 taken 127017 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2082 times.
3628644 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9655 {
9656
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2045 times.
2082 if (slide_slope(this, dx, dy, slopeid))
9657 {
9658 2045 onplatid = 5;
9659
3/4
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 1265 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780 times.
2045 if (dx || dy) push_move(dx, dy);
9660 2045 }
9661 2082 }
9662
2/2
✓ Branch 0 taken 3625997 times.
✓ Branch 1 taken 2647 times.
3628644 if (onplatid <= 0) slopeid = 0;
9663 2647 else --onplatid;
9664
2/2
✓ Branch 0 taken 2809556 times.
✓ Branch 1 taken 819088 times.
3628644 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9665
5/6
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 3628628 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 968 times.
✓ Branch 5 taken 3628644 times.
3629612 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9666 {
9667
2/4
✓ Branch 0 taken 968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 968 times.
968 if (check_slope(this, true) && !toogam)
9668 {
9669 968 slope_info const& s = get_slope(this, true).get_info();
9670 968 bool staircheck = false;
9671
4/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 63 times.
968 if (s.slope() != slopeid && slopeid) staircheck = true;
9672
2/2
✓ Branch 0 taken 931 times.
✓ Branch 1 taken 37 times.
968 if (onplatform) staircheck = true;
9673 968 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9674
9675
4/4
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 28 times.
968 if (dx || dy)
9676 {
9677 940 int32_t pushret = push_move(dx,dy);
9678
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 20 times.
940 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9679
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 830 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 59 times.
940 if (s.slope() != slopeid && slopeid) staircheck = true;
9680
2/2
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 18 times.
940 if (onplatform) staircheck = true;
9681
4/4
✓ Branch 0 taken 908 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 882 times.
940 if(sideview_mode() && slopeid)
9682 882 onplatid = 5;
9683
1/2
✓ Branch 0 taken 940 times.
✗ Branch 1 not taken.
940 if (pushret == 1)
9684 {
9685 dx = -1;
9686 dy = 0;
9687 slope_push_int(s, this, dx, dy, staircheck);
9688 push_move(dx,dy);
9689 }
9690
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 12 times.
940 if (pushret == 2)
9691 {
9692 12 dx = 0;
9693 12 dy = -1;
9694 12 slope_push_int(s, this, dx, dy, staircheck);
9695 12 push_move(dx,dy);
9696 12 }
9697 940 }
9698 968 }
9699 968 }
9700
9701
2/2
✓ Branch 0 taken 3628584 times.
✓ Branch 1 taken 60 times.
3628644 if(ffwarp)
9702 {
9703
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(ffpit)
9704 {
9705 1 ffpit=false;
9706 1 didpit=true;
9707 1 pitx=x;
9708 1 pity=y;
9709 1 }
9710
9711 60 ffwarp=false;
9712 60 dowarp(1,0);
9713 60 }
9714
9715 //Hero->WarpEx
9716
2/2
✓ Branch 0 taken 3628628 times.
✓ Branch 1 taken 16 times.
3628644 if ( FFCore.warpex[wexActive] )
9717 {
9718 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9719 16 FFCore.warpex[wexActive] = 0;
9720 16 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9721
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 16 times.
160 for ( int32_t q = 0; q < wexActive; q++ )
9722 {
9723 144 temp_warpex[q] = FFCore.warpex[q];
9724 144 FFCore.warpex[q] = 0;
9725 144 }
9726 32 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9727 16 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9728 16 }
9729
9730 // walk through bombed doors and fake walls
9731 3628644 bool walk=false;
9732 3628644 int32_t dtype=dBOMBED;
9733
9734
2/2
✓ Branch 0 taken 3582231 times.
✓ Branch 1 taken 46413 times.
3628644 if(pushing>=24) dtype=dWALK;
9735
9736
15/18
✓ Branch 0 taken 2307850 times.
✓ Branch 1 taken 1320794 times.
✓ Branch 2 taken 2287209 times.
✓ Branch 3 taken 20641 times.
✓ Branch 4 taken 2287209 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2284141 times.
✓ Branch 7 taken 3068 times.
✓ Branch 8 taken 2282029 times.
✓ Branch 9 taken 2112 times.
✓ Branch 10 taken 2282000 times.
✓ Branch 11 taken 29 times.
✓ Branch 12 taken 2273472 times.
✓ Branch 13 taken 8528 times.
✓ Branch 14 taken 2273472 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2273472 times.
3628644 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9737 {
9738
12/16
✓ Branch 0 taken 23202 times.
✓ Branch 1 taken 2250270 times.
✓ Branch 2 taken 368715 times.
✓ Branch 3 taken 1881555 times.
✓ Branch 4 taken 368715 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 368715 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 73437 times.
✓ Branch 11 taken 295278 times.
✓ Branch 12 taken 20574 times.
✓ Branch 13 taken 52863 times.
✓ Branch 14 taken 20504 times.
✓ Branch 15 taken 70 times.
2273472 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9739 {
9740 70 walk=true;
9741 70 dir=up;
9742 70 }
9743
9744
12/16
✓ Branch 0 taken 23202 times.
✓ Branch 1 taken 2250270 times.
✓ Branch 2 taken 281356 times.
✓ Branch 3 taken 1968914 times.
✓ Branch 4 taken 304558 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 304558 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 38579 times.
✓ Branch 11 taken 265979 times.
✓ Branch 12 taken 11031 times.
✓ Branch 13 taken 27548 times.
✓ Branch 14 taken 10967 times.
✓ Branch 15 taken 64 times.
2273472 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9745 {
9746 64 walk=true;
9747 64 dir=down;
9748 64 }
9749
9750
10/14
✓ Branch 0 taken 23202 times.
✓ Branch 1 taken 2250270 times.
✓ Branch 2 taken 3306 times.
✓ Branch 3 taken 2246964 times.
✓ Branch 4 taken 26508 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26508 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 13486 times.
✓ Branch 11 taken 13022 times.
✓ Branch 12 taken 13437 times.
✓ Branch 13 taken 49 times.
2273472 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9751 {
9752 49 walk=true;
9753 49 dir=left;
9754 49 }
9755
9756
10/14
✓ Branch 0 taken 2250270 times.
✓ Branch 1 taken 23202 times.
✓ Branch 2 taken 8642 times.
✓ Branch 3 taken 2241628 times.
✓ Branch 4 taken 31844 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31844 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 17839 times.
✓ Branch 11 taken 14005 times.
✓ Branch 12 taken 17781 times.
✓ Branch 13 taken 58 times.
2273472 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9757 {
9758 58 walk=true;
9759 58 dir=right;
9760 58 }
9761 2273472 }
9762
9763
2/2
✓ Branch 0 taken 3628403 times.
✓ Branch 1 taken 241 times.
3628644 if(walk)
9764 {
9765 241 hclk=0;
9766 241 drawguys=false;
9767
9768
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 68 times.
241 if(dtype==dWALK)
9769 {
9770 68 sfx(tmpscr->secretsfx);
9771 68 }
9772
9773 241 action=none; FFCore.setHeroAction(none);
9774 241 stepforward(29, true);
9775 241 action=scrolling; FFCore.setHeroAction(scrolling);
9776 241 pushing=false;
9777 241 }
9778
9779
4/6
✓ Branch 0 taken 66803 times.
✓ Branch 1 taken 3561841 times.
✓ Branch 2 taken 66803 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 66803 times.
3628644 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9780 {
9781
1/2
✓ Branch 0 taken 66803 times.
✗ Branch 1 not taken.
66803 if(heart_beep)
9782 {
9783 66803 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9784 66803 }
9785 else
9786 {
9787 if ( heart_beep_timer == -1 )
9788 {
9789 heart_beep_timer = 70;
9790 }
9791
9792 if ( heart_beep_timer > 0 )
9793 {
9794 --heart_beep_timer;
9795 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9796 }
9797 else
9798 {
9799 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9800 }
9801 }
9802 66803 }
9803 else
9804 {
9805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3561841 times.
3561841 if ( heart_beep_timer > -2 )
9806 {
9807 3561841 heart_beep_timer = -1;
9808 3561841 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9809 3561841 }
9810 }
9811
9812
2/2
✓ Branch 0 taken 3628130 times.
✓ Branch 1 taken 514 times.
3628644 if(rSbtn())
9813 {
9814 514 int32_t tmp_subscr_clk = frame;
9815
9816 514 int32_t save_type = 0;
9817
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 506 times.
✗ Branch 3 not taken.
514 switch(lsave)
9818 {
9819 case 0:
9820 {
9821
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 465 times.
506 if( FFCore.runActiveSubscreenScriptEngine() )
9822 {
9823 41 break;
9824 }
9825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 465 times.
465 else if ( !stopSubscreenFalling() )
9826 {
9827 465 conveyclk=3;
9828 465 dosubscr(&QMisc);
9829 465 newscr_clk += frame - tmp_subscr_clk;
9830 465 }
9831 465 break;
9832 }
9833
9834
9835 case 2:
9836 save_type = 1;
9837 [[fallthrough]];
9838 case 1:
9839
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
9840 7 trigger_save(combobuf[last_savepoint_id]);
9841 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9842 7 break;
9843 }
9844 514 }
9845
9846
2/2
✓ Branch 0 taken 243736 times.
✓ Branch 1 taken 3384906 times.
3628642 if (!checkstab() )
9847 {
9848 /*
9849 for(int32_t q=0; q<176; q++)
9850 {
9851 set_bit(screengrid,q,0);
9852 }
9853
9854 for(int32_t q=0; q<MAXFFCS; q++)
9855 set_bit(ffcgrid, q, 0);
9856 */
9857 3384906 }
9858
9859 3628642 check_conveyor();
9860 3628642 PhantomsCleanup();
9861 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9862
2/2
✓ Branch 0 taken 3620132 times.
✓ Branch 1 taken 8510 times.
3628642 if(attack==wHammer)
9863 {
9864
5/8
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 8424 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 86 times.
8510 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9865 {
9866
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 38 times.
86 switch(dir) //Hero's dir
9867 {
9868 case up:
9869
5/10
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27 times.
✗ Branch 9 not taken.
27 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9870 27 break;
9871
9872 case down:
9873
5/10
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 17 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17 times.
✗ Branch 9 not taken.
17 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9874 17 break;
9875
9876 case left:
9877
5/10
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
4 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9878 4 break;
9879
9880 case right:
9881
5/10
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 38 times.
✗ Branch 9 not taken.
38 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9882 38 break;
9883 }
9884
9885 86 }
9886 8510 }
9887
9888 3628642 handleSpotlights();
9889
9890
2/2
✓ Branch 0 taken 3628423 times.
✓ Branch 1 taken 219 times.
3628642 if(getOnSideviewLadder())
9891 {
9892
5/8
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
219 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9893 {
9894 5 setOnSideviewLadder(false);
9895 5 }
9896
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
9897 {
9898 40 setDir(up);
9899 40 }
9900 219 }
9901
2/2
✓ Branch 0 taken 3557026 times.
✓ Branch 1 taken 71616 times.
3628642 if (justmoved > 0) --justmoved;
9902
9903 3628642 return false;
9904 3628963 }
9905
9906 6470 bool HeroClass::push_pixel(zfix dx, zfix dy)
9907 {
9908
2/4
✓ Branch 0 taken 6470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6470 times.
✗ Branch 3 not taken.
6470 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9909
3/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 3014 times.
✓ Branch 2 taken 3456 times.
✗ Branch 3 not taken.
6470 if(dx && dy)
9910 {
9911 bool r = push_pixel(0,dy);
9912 bool r2 = push_pixel(dx,0);
9913 return r && r2;
9914 }
9915
2/2
✓ Branch 0 taken 3091 times.
✓ Branch 1 taken 3379 times.
6470 if(dx < 0)
9916 {
9917
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
6182 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9918
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
3091 || solpush_walkflag(x+dx,y+8,1,this)
9919
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3091 times.
✓ Branch 2 taken 2680 times.
✓ Branch 3 taken 411 times.
3091 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9920 {
9921 3091 x += dx;
9922 3091 return true;
9923 }
9924 return false;
9925 }
9926
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 3014 times.
3379 else if(dx > 0)
9927 {
9928
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
730 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9929
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 || solpush_walkflag(x+15+dx,y+8,1,this)
9930
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 147 times.
365 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9931 {
9932 365 x += dx;
9933 365 return true;
9934 }
9935 return false;
9936 }
9937
2/2
✓ Branch 0 taken 1757 times.
✓ Branch 1 taken 1257 times.
3014 else if(dy < 0)
9938 {
9939
1/2
✓ Branch 0 taken 1757 times.
✗ Branch 1 not taken.
3514 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9940
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757 times.
✓ Branch 2 taken 1623 times.
✓ Branch 3 taken 134 times.
1757 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9941 {
9942 1757 y += dy;
9943 1757 return true;
9944 }
9945 return false;
9946 }
9947
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 else if(dy > 0)
9948 {
9949
2/2
✓ Branch 0 taken 1220 times.
✓ Branch 1 taken 37 times.
2494 if(!(solpush_walkflag(x,y+15+dy,2,this)
9950
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1237 times.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 1013 times.
1257 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
9951 {
9952 1220 y += dy;
9953 1220 return true;
9954 }
9955 37 return false;
9956 }
9957 return false;
9958 6470 }
9959 3407 int32_t HeroClass::push_move(zfix dx, zfix dy)
9960 {
9961 3407 int32_t ret = 0;
9962
4/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 4259 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 4308 times.
7715 while(dx || dy)
9963 {
9964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4308 times.
4308 if(check_pitslide() != -1)
9965 break;
9966
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 3014 times.
4308 if(dy)
9967 {
9968
2/2
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 886 times.
3014 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
9969 3014 dy -= cy;
9970
2/2
✓ Branch 0 taken 2977 times.
✓ Branch 1 taken 37 times.
3014 if(!push_pixel(0,cy))
9971 {
9972 37 dy = 0;
9973 37 ret |= 2;
9974 37 }
9975 3014 }
9976
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 3456 times.
4308 if(dx)
9977 {
9978
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 2012 times.
3456 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
9979 3456 dx -= cx;
9980
1/2
✓ Branch 0 taken 3456 times.
✗ Branch 1 not taken.
3456 if(!push_pixel(cx,0))
9981 {
9982 dx = 0;
9983 ret |= 1;
9984 }
9985 3456 }
9986 }
9987 3407 return ret;
9988 }
9989
9990 3628936 bool HeroClass::setSolid(bool set)
9991 {
9992
1/2
✓ Branch 0 taken 3628936 times.
✗ Branch 1 not taken.
3628936 bool actual = set && !toogam; //not solid when noclipping
9993 3628936 bool ret = solid_object::setSolid(actual);
9994 3628936 solid = set;
9995 3628936 return ret;
9996 }
9997
9998 13071 void HeroClass::solid_push(solid_object* obj)
9999 {
10000
1/2
✓ Branch 0 taken 13071 times.
✗ Branch 1 not taken.
13071 if(obj == this) return; //can't push self
10001
10002 13071 zfix dx, dy;
10003 13071 int32_t hdir = -1;
10004 13071 solid_push_int(obj,dx,dy,hdir);
10005
10006
4/4
✓ Branch 0 taken 12146 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 11881 times.
✓ Branch 3 taken 265 times.
13071 if(!dx && !dy) return;
10007
10008 1190 obj->doContactDamage(hdir);
10009
10010 1190 bool t = obj->getTempNonsolid();
10011 1190 obj->setTempNonsolid(true);
10012
10013 1190 push_move(dx,dy);
10014
10015 1190 obj->setTempNonsolid(t);
10016 13071 }
10017
10018 // A routine used exclusively by startwpn,
10019 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10020 476 void HeroClass::deselectbombs(int32_t super)
10021 {
10022
6/10
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 471 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 471 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 471 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 471 times.
476 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10023
2/6
✓ Branch 0 taken 471 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
471 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10024 {
10025
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
471 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10026 471 Bwpn = Bweapon(temp);
10027 471 directItemB = directItem;
10028 471 game->bwpn = temp;
10029 471 }
10030
10031 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10032 {
10033 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10034 Xwpn = Bweapon(temp);
10035 directItemX = directItem;
10036 game->xwpn = temp;
10037 }
10038 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10039 {
10040 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10041 Ywpn = Bweapon(temp);
10042 directItemY = directItem;
10043 game->ywpn = temp;
10044 }
10045 else
10046 {
10047 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10048 Awpn = Bweapon(temp);
10049 directItemA = directItem;
10050 game->awpn = temp;
10051 }
10052 476 }
10053
10054 int32_t potion_life=0;
10055 int32_t potion_magic=0;
10056
10057 bool HeroClass::mirrorBonk()
10058 {
10059 zfix tx = x, ty = y, tz = z;
10060 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10061 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10062 execute(info);
10063 bool fail = info.isUnwalkable();
10064
10065 if(!fail) //not solid, but check for water/pits...
10066 {
10067 //{ Check water collision.... GAAAAAAAH THIS IS A MESS
10068 int32_t water = 0;
10069 int32_t types[4] = {0};
10070 int32_t x1 = x+4, x2 = x+11,
10071 y1 = y+9, y2 = y+15;
10072 if (get_bit(quest_rules, qr_SMARTER_WATER))
10073 {
10074 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10075 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10076 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10077 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10078 }
10079 else
10080 {
10081 types[0] = COMBOTYPE(x1,y1);
10082
10083 if(MAPFFCOMBO(x1,y1))
10084 types[0] = FFCOMBOTYPE(x1,y1);
10085
10086 types[1] = COMBOTYPE(x1,y2);
10087
10088 if(MAPFFCOMBO(x1,y2))
10089 types[1] = FFCOMBOTYPE(x1,y2);
10090
10091 types[2] = COMBOTYPE(x2,y1);
10092
10093 if(MAPFFCOMBO(x2,y1))
10094 types[2] = FFCOMBOTYPE(x2,y1);
10095
10096 types[3] = COMBOTYPE(x2,y2);
10097
10098 if(MAPFFCOMBO(x2,y2))
10099 types[3] = FFCOMBOTYPE(x2,y2);
10100
10101 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10102 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10103 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10104
10105 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10106 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10107 water = typec;
10108 }
10109 if(water > 0)
10110 {
10111 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10112 {
10113 fail = true;
10114 }
10115 }
10116 //}
10117 if(pitslide() || fallclk)
10118 fail = true;
10119 fallclk = 0;
10120 }
10121 x = tx; y = ty; z = tz;
10122 return fail;
10123 }
10124
10125 void HeroClass::doMirror(int32_t mirrorid)
10126 {
10127 if(z > 0 || fakez > 0) return; //No mirror in air
10128 if(mirrorid < 0)
10129 mirrorid = current_item_id(itype_mirror);
10130 if(mirrorid < 0) return;
10131
10132 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10133 {
10134 item_error();
10135 return;
10136 }
10137 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10138 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10139 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10140 for(auto pos : posarr)
10141 {
10142 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10143 {
10144 item_error();
10145 return;
10146 }
10147 }
10148
10149 itemdata const& mirror = itemsbuf[mirrorid];
10150 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10151 {
10152 paymagiccost(mirrorid);
10153 if(mirror.usesound2) sfx(mirror.usesound2);
10154
10155 doWarpEffect(mirror.misc2, true);
10156 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10157 {
10158 Quit = qCONT;
10159 skipcont = 1;
10160 }
10161 else //Act as Farore's Wind
10162 {
10163 int32_t nayrutemp=nayruitem;
10164 restart_level();
10165 nayruitem=nayrutemp;
10166 magicitem=-1;
10167 magiccastclk=0;
10168 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10169 }
10170 }
10171 else
10172 {
10173 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10174 int32_t offscr = currscr - DMaps[currdmap].xoff;
10175 if(destdmap < 0)
10176 return;
10177 int32_t destscr = DMaps[destdmap].xoff + offscr;
10178 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10179 return;
10180 paymagiccost(mirrorid);
10181
10182 //Store some values to restore if 'warp fails'
10183 int32_t tLastEntrance = lastentrance,
10184 tLastEntranceDMap = lastentrance_dmap,
10185 tContScr = game->get_continue_scrn(),
10186 tContDMap = game->get_continue_dmap(),
10187 tPortalDMap = game->portalsrcdmap;
10188 int32_t sourcescr = currscr, sourcedmap = currdmap;
10189 zfix tx = x, ty = y, tz = z;
10190 game->portalsrcdmap = -1;
10191 action = none; FFCore.setHeroAction(none);
10192
10193 //Warp to new dmap
10194 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10195 mirror.usesound, 0, -1);
10196
10197 //Check for valid landing location
10198 if(mirrorBonk()) //Invalid landing, warp back!
10199 {
10200 action = none; FFCore.setHeroAction(none);
10201 lastentrance = tLastEntrance;
10202 lastentrance_dmap = tLastEntranceDMap;
10203 game->set_continue_scrn(tContScr);
10204 game->set_continue_dmap(tContDMap);
10205 x = tx;
10206 y = ty;
10207 z = tz;
10208 game->portalsrcdmap = tPortalDMap;
10209 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10210 mirror.usesound, 0, -1);
10211 }
10212 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10213 {
10214 //Place the portal
10215 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10216 //Since it was placed after loading this screen, load the portal object now
10217 game->load_portal();
10218 //Don't immediately trigger the warp back
10219 can_mirror_portal = false;
10220
10221 //Set continue point
10222 if(currdmap != game->get_continue_dmap())
10223 {
10224 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10225 }
10226 game->set_continue_dmap(currdmap);
10227 lastentrance_dmap = currdmap;
10228 lastentrance = game->get_continue_scrn();
10229 }
10230 }
10231 }
10232
10233 3628648 void HeroClass::handle_passive_buttons()
10234 {
10235 3628648 do_liftglove(-1,true);
10236 3628648 do_jump(-1,true);
10237 3628648 }
10238
10239 static bool did_passive_jump = false;
10240 3628715 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10241 {
10242
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 3628648 times.
3628715 if(passive) did_passive_jump = false;
10243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 else if(did_passive_jump) return false; //don't jump twice in the same frame
10244
10245
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 3628648 times.
3628715 if(jumpid < 0)
10246 3628648 jumpid = current_item_id(itype_rocs,true,true);
10247
10248
2/2
✓ Branch 0 taken 3443309 times.
✓ Branch 1 taken 185406 times.
3628715 if(unsigned(jumpid) >= MAXITEMS) return false;
10249
4/4
✓ Branch 0 taken 185295 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 1411 times.
✓ Branch 3 taken 183884 times.
185406 if(inlikelike || charging) return false;
10250
1/2
✓ Branch 0 taken 183884 times.
✗ Branch 1 not taken.
183884 if(!checkitem_jinx(jumpid)) return false;
10251
10252 183884 itemdata const& itm = itemsbuf[jumpid];
10253
10254 183884 bool standing = isStanding(true);
10255
3/4
✓ Branch 0 taken 181539 times.
✓ Branch 1 taken 2345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2345 times.
183884 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10256
4/6
✓ Branch 0 taken 183884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2345 times.
✓ Branch 3 taken 181539 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2345 times.
183884 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10257
2/4
✓ Branch 0 taken 181539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181539 times.
181539 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10258 {
10259 item_error();
10260 return false;
10261 }
10262
10263 181539 byte intbtn = byte(itm.misc2&0xFF);
10264
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 181478 times.
181539 if(passive)
10265 {
10266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 181478 times.
181478 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10267 181478 return false; //not pressed
10268 }
10269
10270 61 paymagiccost(jumpid);
10271
10272
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(!standing)
10273 {
10274 ++extra_jump_count;
10275 fall = 0;
10276 fakefall = 0;
10277 if(hoverclk > 0)
10278 hoverclk = -hoverclk;
10279 }
10280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(itm.flags & ITEM_FLAG1)
10281 setFall(fall - itm.power);
10282 61 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10283 61 coyotetime = 65535; //jumped, so no coyotetime
10284 61 setOnSideviewLadder(false);
10285
10286 // Reset the ladder, unless on an unwalkable combo
10287
3/10
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 61 times.
✗ Branch 9 not taken.
61 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10288 reset_ladder();
10289
10290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(itm.usesound)
10291 61 sfx(itm.usesound,pan(x.getInt()));
10292
10293
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(passive) did_passive_jump = true;
10294 61 return true;
10295 3628715 }
10296 928 void HeroClass::drop_liftwpn()
10297 {
10298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 928 times.
928 if(!lift_wpn) return;
10299
10300 handle_lift(false); //sets position properly, accounting for large weapons
10301 auto liftid = current_item_id(itype_liftglove,true,true);
10302 itemdata const& glove = itemsbuf[liftid];
10303 if(glove.flags & ITEM_FLAG1)
10304 {
10305 lift_wpn->z = 0;
10306 lift_wpn->fakez = liftheight;
10307 }
10308 else lift_wpn->z = liftheight;
10309 lift_wpn->dir = dir;
10310 lift_wpn->step = 0;
10311 lift_wpn->fakefall = 0;
10312 lift_wpn->fall = 0;
10313 if(glove.flags & ITEM_FLAG1)
10314 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10315 else
10316 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10317 Lwpns.add(lift_wpn);
10318 lift_wpn = nullptr;
10319 928 }
10320 3628648 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10321 {
10322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3628648 times.
3628648 if(liftid < 0)
10323 3628648 liftid = current_item_id(itype_liftglove,true,true);
10324
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 3628403 times.
3628648 if(!can_lift(liftid)) return;
10325 245 itemdata const& glove = itemsbuf[liftid];
10326 245 byte intbtn = byte(glove.misc1&0xFF);
10327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if(passive)
10328 {
10329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10330 245 return; //not pressed
10331 }
10332
10333 bool had_weapon = lift_wpn;
10334
10335 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10336 (checkbunny(liftid) && checkmagiccost(liftid))))
10337 {
10338 item_error();
10339 return;
10340 }
10341 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10342 return;
10343
10344 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10345 if(glove.script)
10346 {
10347 if(!paidmagic)
10348 {
10349 paidmagic = true;
10350 paymagiccost(liftid);
10351 }
10352
10353 ri = &(itemScriptData[liftid]);
10354 for ( int32_t q = 0; q < 1024; q++ )
10355 item_stack[liftid][q] = 0xFFFF;
10356 ri->Clear();
10357 item_doscript[liftid] = 1;
10358 itemscriptInitialised[liftid] = 0;
10359 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10360
10361 bool has_weapon = lift_wpn;
10362 if(has_weapon != had_weapon) //Item action script changed the lift information
10363 {
10364 if(passive)
10365 {
10366 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10367 }
10368 return;
10369 }
10370 }
10371
10372 if(lift_wpn)
10373 {
10374 if(!paidmagic)
10375 {
10376 paidmagic = true;
10377 paymagiccost(liftid);
10378 }
10379 if(!liftclk)
10380 {
10381 //Throw the weapon!
10382 //hero's direction and position
10383 handle_lift(false); //sets position properly, accounting for large weapons
10384 if(glove.flags & ITEM_FLAG1)
10385 {
10386 lift_wpn->z = 0;
10387 lift_wpn->fakez = liftheight;
10388 }
10389 else lift_wpn->z = liftheight;
10390 lift_wpn->dir = dir;
10391 //Configured throw speed in both axes
10392 lift_wpn->step = zfix(glove.misc2)/100;
10393 if(glove.flags & ITEM_FLAG1)
10394 {
10395 lift_wpn->fakefall = -glove.misc3;
10396 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10397 }
10398 else
10399 {
10400 lift_wpn->fall = -glove.misc3;
10401 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10402 }
10403 Lwpns.add(lift_wpn);
10404 lift_wpn = nullptr;
10405 if(glove.usesound2)
10406 sfx(glove.usesound2,pan(int32_t(x)));
10407 }
10408
10409 if(passive)
10410 {
10411 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10412 }
10413 return;
10414 }
10415
10416 //Check for a liftable combo
10417 zfix bx, by;
10418 zfix bx2, by2;
10419 switch(dir)
10420 {
10421 case up:
10422 by = y + (bigHitbox ? -2 : 6);
10423 by2 = by;
10424 bx = x + 4;
10425 bx2 = bx + 8;
10426 break;
10427 case down:
10428 by = y + 17;
10429 by2 = by;
10430 bx = x + 4;
10431 bx2 = bx + 8;
10432 break;
10433 case left:
10434 by = y + (bigHitbox ? 0 : 8);
10435 by2 = y + 8;
10436 bx = x - 2;
10437 bx2 = x - 2;
10438 break;
10439 case right:
10440 by = y + (bigHitbox ? 0 : 8);
10441 by2 = y + 8;
10442 bx = x + 17;
10443 bx2 = x + 17;
10444 break;
10445 }
10446 int32_t pos = COMBOPOS_B(bx,by);
10447 int32_t pos2 = COMBOPOS_B(bx2,by2);
10448 int32_t foundpos = -1;
10449
10450 bool lifted = false;
10451 for(auto lyr = 6; lyr >= 0; --lyr)
10452 {
10453 mapscr* scr = FFCore.tempScreens[lyr];
10454 if(pos > -1)
10455 {
10456 newcombo const& cmb = combobuf[scr->data[pos]];
10457 if(cmb.liftflags & LF_LIFTABLE)
10458 {
10459 if(do_lift_combo(lyr,pos,liftid))
10460 {
10461 lifted = true;
10462 break;
10463 }
10464 }
10465 }
10466 if(pos != pos2 && pos2 > -1)
10467 {
10468 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10469 if(cmb2.liftflags & LF_LIFTABLE)
10470 {
10471 if(do_lift_combo(lyr,pos2,liftid))
10472 {
10473 lifted = true;
10474 break;
10475 }
10476 }
10477 }
10478 }
10479 if(!lifted) return;
10480 if(!paidmagic)
10481 {
10482 paidmagic = true;
10483 paymagiccost(liftid);
10484 }
10485 if(passive)
10486 {
10487 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10488 }
10489 return;
10490 3628648 }
10491 void HeroClass::handle_lift(bool dec)
10492 {
10493 lift_wpn->fakez = 0;
10494 if(!lift_wpn) liftclk = 0;
10495 if(liftclk <= (dec?1:0))
10496 {
10497 liftclk = 0;
10498 tliftclk = 0;
10499 if(lift_wpn)
10500 {
10501 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10502 {
10503 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10504 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10505 }
10506 else
10507 {
10508 lift_wpn->x = x;
10509 lift_wpn->y = y;
10510 }
10511 lift_wpn->z = liftheight;
10512 }
10513 if(action == lifting)
10514 {
10515 action = none; FFCore.setHeroAction(none);
10516 }
10517 return;
10518 }
10519 if(dec) --liftclk;
10520 double xdist, ydist;
10521 double perc = (liftclk/double(tliftclk));
10522 switch(dir)
10523 {
10524 case up:
10525 {
10526 xdist = 0;
10527 ydist = -16;
10528 if(lift_wpn->txsz > 1)
10529 {
10530 xdist = -((lift_wpn->txsz*8)-8);
10531 }
10532 else xdist = 0;
10533 if(lift_wpn->tysz > 1)
10534 {
10535 ydist = -(lift_wpn->tysz*16);
10536 }
10537 ydist *= perc;
10538 break;
10539 }
10540 case down:
10541 {
10542 xdist = 0;
10543 ydist = 16;
10544 if(lift_wpn->txsz > 1)
10545 {
10546 xdist = -((lift_wpn->txsz*8)-8);
10547 }
10548 else xdist = 0;
10549 ydist *= perc;
10550 break;
10551 }
10552 case left:
10553 {
10554 xdist = -16;
10555 ydist = 0;
10556 if(lift_wpn->txsz > 1)
10557 {
10558 xdist = -(lift_wpn->txsz*16);
10559 }
10560 if(lift_wpn->tysz > 1)
10561 {
10562 ydist = -((lift_wpn->tysz*8)-8);
10563 }
10564 else ydist = 0;
10565 xdist *= perc;
10566 break;
10567 }
10568 case right:
10569 {
10570 xdist = 16;
10571 ydist = 0;
10572 if(lift_wpn->tysz > 1)
10573 {
10574 ydist = -((lift_wpn->tysz*8)-8);
10575 }
10576 else ydist = 0;
10577 xdist *= perc;
10578 break;
10579 }
10580 }
10581
10582 lift_wpn->x = x + xdist;
10583 lift_wpn->y = y + ydist;
10584 lift_wpn->z = liftheight*(1.0-perc);
10585 }
10586 3628648 bool HeroClass::can_lift(int32_t gloveid)
10587 {
10588
2/2
✓ Branch 0 taken 3628403 times.
✓ Branch 1 taken 245 times.
3628648 if(unsigned(gloveid) >= MAXITEMS) return false;
10589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if(lstunclock) return false;
10590
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(!checkitem_jinx(gloveid)) return false;
10591 245 itemdata const& glove = itemsbuf[gloveid];
10592
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
✗ Branch 2 not taken.
245 switch(action)
10593 {
10594 case none: case walking:
10595 245 break;
10596
10597 case swimming:
10598 if(glove.flags & ITEM_FLAG2)
10599 break;
10600 return false;
10601
10602 default:
10603 return false;
10604 }
10605 245 return true;
10606 3628648 }
10607 void HeroClass::lift(weapon* w, byte timer, zfix height)
10608 {
10609 lift_wpn = w;
10610 liftclk = timer;
10611 tliftclk = timer;
10612 if(height < 0)
10613 liftheight = 0;
10614 else liftheight = height;
10615 }
10616
10617 void HeroClass::doSwitchHook(byte style)
10618 {
10619 hs_switcher = true;
10620 pull_hero = true;
10621 //{ Load hook weapons, set them to obey special drawing
10622 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10623 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10624
10625 if(w)
10626 w->switch_hooked = true;
10627 if(hw)
10628 hw->switch_hooked = true;
10629 for(int32_t j=0; j<chainlinks.Count(); j++)
10630 {
10631 chainlinks.spr(j)->switch_hooked = true;
10632 }
10633 //}
10634 if(hooked_combopos > -1)
10635 {
10636 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10637 hooked_layerbits = 0;
10638 for(auto q = 0; q < 7; ++q)
10639 hooked_undercombos[q] = -1;
10640 uint16_t plpos = COMBOPOS(x+8,y+8);
10641 for(auto q = max_layer; q > -1; --q)
10642 {
10643 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10644 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10645 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10646 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10647 bool isPush = false;
10648 if(isSwitchHookable(cmb))
10649 {
10650 if(cmb.type == cSWITCHHOOK)
10651 {
10652 uint16_t plpos = COMBOPOS(x+8,y+8);
10653 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10654 continue; //don't swap with non-zero combo
10655 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10656 continue; //too low a switchhook level
10657 hooked_layerbits |= 1<<q; //Swapping
10658 if(cmb.usrflags&cflag3)
10659 {
10660 if(cmb.usrflags&cflag6)
10661 {
10662 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10663 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10664 }
10665 else
10666 {
10667 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10668 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10669 }
10670 }
10671 else
10672 {
10673 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10674 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10675 isPush = true;
10676 }
10677 }
10678 else if(isCuttableType(cmb.type))
10679 {
10680 if(isCuttableNextType(cmb.type))
10681 {
10682 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10683 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10684 }
10685 else
10686 {
10687 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10688 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10689 }
10690 hooked_layerbits |= 1<<q; //Swapping
10691 }
10692 else
10693 {
10694 hooked_layerbits |= 1<<q; //Swapping
10695 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10696 }
10697 }
10698 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10699 {
10700 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10701 && hasMainGuy())
10702 {
10703 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10704 continue;
10705 }
10706 if(fl1 == mfPUSHED)
10707 {
10708 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10709 continue;
10710 }
10711 if(!isPush) switch(fl1)
10712 {
10713 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10714 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10715 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10716 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10717 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10718 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10719 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10720 isPush = true;
10721 }
10722 if(!isPush) switch(cmb.flag)
10723 {
10724 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10725 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10726 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10727 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10728 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10729 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10730 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10731 isPush = true;
10732 }
10733 if(isPush) //Check for block holes / triggers
10734 {
10735 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10736 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10737 {
10738 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10739 }
10740 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10741 {
10742 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10743 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10744 {
10745 if(lyr == q) continue;
10746 switch(FFCore.tempScreens[q]->sflag[plpos])
10747 {
10748 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10749 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10750 lyr=7;
10751 break;
10752 }
10753 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10754 {
10755 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10756 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10757 lyr=7;
10758 break;
10759 }
10760 }
10761 }
10762 }
10763 }
10764 }
10765 }
10766 switch_hooked = true;
10767 switchhookstyle = style;
10768 switch(style)
10769 {
10770 default: case swPOOF:
10771 {
10772 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10773 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10774 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10775 if(hooked_combopos > -1)
10776 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10777 else if(switching_object)
10778 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10779 break;
10780 }
10781 case swFLICKER:
10782 {
10783 switchhookmaxtime = switchhookclk = 64;
10784 break;
10785 }
10786 case swRISE:
10787 {
10788 switchhookmaxtime = switchhookclk = 64;
10789 break;
10790 }
10791 }
10792 }
10793
10794 18062 bool HeroClass::startwpn(int32_t itemid)
10795 {
10796
1/2
✓ Branch 0 taken 18062 times.
✗ Branch 1 not taken.
18062 if(itemid < 0) return false;
10797 18062 itemdata const& itm = itemsbuf[itemid];
10798
5/6
✓ Branch 0 taken 4063 times.
✓ Branch 1 taken 13999 times.
✓ Branch 2 taken 3465 times.
✓ Branch 3 taken 10534 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
18090 if(((dir==up && y<24) || (dir==down && y>128) ||
10799
6/6
✓ Branch 0 taken 5333 times.
✓ Branch 1 taken 5201 times.
✓ Branch 2 taken 5197 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 28 times.
✓ Branch 5 taken 18030 times.
18062 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10800 28 return false;
10801
10802 18034 int32_t wx=x;
10803 18034 int32_t wy=y-fakez;
10804 18034 int32_t wz=z;
10805 18034 bool ret = true;
10806
10807
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4055 times.
✓ Branch 2 taken 3458 times.
✓ Branch 3 taken 5324 times.
✓ Branch 4 taken 5193 times.
18034 switch(dir)
10808 {
10809 case up:
10810 4055 wy-=16;
10811 4055 break;
10812
10813 case down:
10814 3458 wy+=16;
10815 3458 break;
10816
10817 case left:
10818 5324 wx-=16;
10819 5324 break;
10820
10821 case right:
10822 5193 wx+=16;
10823 5193 break;
10824 }
10825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18034 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10826
10827
14/27
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 550 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 114 times.
✓ Branch 11 taken 464 times.
✓ Branch 12 taken 12 times.
✓ Branch 13 taken 1198 times.
✓ Branch 14 taken 8937 times.
✓ Branch 15 taken 896 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 378 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 5356 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18034 switch(itm.family)
10828 {
10829 case itype_liftglove:
10830 {
10831 do_liftglove(itemid,false);
10832 dowpn = -1;
10833 ret = false;
10834 break;
10835 }
10836 case itype_potion:
10837 {
10838
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10839 {
10840 return item_error();
10841 }
10842
10843 20 paymagiccost(itemid);
10844
10845
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if(itm.misc1 || itm.misc2)
10846 {
10847 20 refill_what=REFILL_ALL;
10848 20 refill_why=itemid;
10849 20 StartRefill(REFILL_ALL);
10850 20 potion_life = game->get_life();
10851 20 potion_magic = game->get_magic();
10852
10853 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10854 //music_pause();
10855 20 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10856
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 20 times.
4454 while(refill())
10857 {
10858 4434 do_refill_waitframe();
10859 }
10860
10861 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10862 //music_resume();
10863 20 ret = false;
10864 20 }
10865
10866 20 break;
10867 }
10868 case itype_bottle:
10869 {
10870 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10871 {
10872 return item_error();
10873 }
10874 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10875 return false;
10876
10877 size_t bind = game->get_bottle_slot(itm.misc1);
10878 bool paidmagic = false;
10879 if(itm.script)
10880 {
10881 paidmagic = true;
10882 paymagiccost(itemid);
10883
10884 ri = &(itemScriptData[itemid]);
10885 for ( int32_t q = 0; q < 1024; q++ )
10886 item_stack[itemid][q] = 0xFFFF;
10887 ri->Clear();
10888 item_doscript[itemid] = 1;
10889 itemscriptInitialised[itemid] = 0;
10890 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
10891 bind = game->get_bottle_slot(itm.misc1);
10892 }
10893 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
10894 if(bt)
10895 {
10896 word toFill[3] = { 0 };
10897 for(size_t q = 0; q < 3; ++q)
10898 {
10899 char c = bt->counter[q];
10900 if(c > -1)
10901 {
10902 if(bt->flags & (1<<q))
10903 {
10904 toFill[q] = (bt->amount[q]==100)
10905 ? game->get_maxcounter(c)
10906 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
10907 }
10908 else toFill[q] = bt->amount[q];
10909 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
10910 {
10911 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
10912 }
10913 }
10914 }
10915 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
10916 bool run = max > 0;
10917 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
10918 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
10919 else
10920 {
10921 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
10922 run = true;
10923 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
10924 run = true;
10925 }
10926 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
10927 {
10928 if(bt->flags & BTFLAG_CURESWJINX)
10929 {
10930 swordclk = 0;
10931 verifyAWpn();
10932 }
10933 if(bt->flags & BTFLAG_CUREITJINX)
10934 itemclk = 0;
10935 if(!paidmagic)
10936 paymagiccost(itemid);
10937 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10938 sfx(itm.usesound,pan(x.getInt()));
10939 for(size_t q = 0; q < 20; ++q)
10940 do_refill_waitframe();
10941 double inc = max/60.0; //1 second
10942 double xtra[3]{ 0 };
10943 for(size_t q = 0; q < 60; ++q)
10944 {
10945 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
10946 sfx(QMisc.miscsfx[sfxREFILL]);
10947 for(size_t j = 0; j < 3; ++j)
10948 {
10949 xtra[j] += inc;
10950 word f = floor(xtra[j]);
10951 xtra[j] -= f;
10952 if(toFill[j] > f)
10953 {
10954 toFill[j] -= f;
10955 game->change_counter(f,bt->counter[j]);
10956 }
10957 else if(toFill[j])
10958 {
10959 game->change_counter(toFill[j],bt->counter[j]);
10960 toFill[j] = 0;
10961 }
10962 }
10963 do_refill_waitframe();
10964 }
10965 for(size_t j = 0; j < 3; ++j)
10966 {
10967 if(toFill[j])
10968 {
10969 game->change_counter(toFill[j],bt->counter[j]);
10970 toFill[j] = 0;
10971 }
10972 }
10973 for(size_t q = 0; q < 20; ++q)
10974 do_refill_waitframe();
10975 game->set_bottle_slot(itm.misc1, bt->next_type);
10976 }
10977 }
10978
10979 dowpn = -1;
10980 ret = false;
10981 break;
10982 }
10983
10984 case itype_note:
10985 {
10986 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10987 {
10988 return item_error();
10989 }
10990 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
10991 {
10992 sfx(itm.usesound);
10993 donewmsg(itm.misc1);
10994 paymagiccost(itemid);
10995 }
10996 dowpn = -1;
10997 ret = false;
10998 break;
10999 }
11000
11001 case itype_mirror:
11002 doMirror(itemid);
11003 if(Quit)
11004 return false;
11005 ret = false;
11006 break;
11007
11008 case itype_rocs:
11009 {
11010
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 6 times.
67 if(!do_jump(itemid,false)) return false;
11011 61 ret = false;
11012 }
11013 61 break;
11014
11015 case itype_letter:
11016 {
11017
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 if(current_item(itype_letter)==i_letter &&
11018
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11019
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].guy &&
11020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11021
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11022 3 checkbunny(itemid)
11023 )
11024 {
11025 3 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11026
11027
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(usedid != -1)
11028 3 getitem(usedid, true, true);
11029
11030 3 sfx(tmpscr[currscr<128?0:1].secretsfx);
11031 3 setupscreen();
11032 3 action=none; FFCore.setHeroAction(none);
11033 3 }
11034
11035 3 ret = false;
11036 }
11037 3 break;
11038
11039 case itype_whistle:
11040 {
11041 bool whistleflag;
11042
11043
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 106 times.
114 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11044 {
11045 8 return item_error();
11046 }
11047
11048 106 paymagiccost(itemid);
11049 106 sfx(itm.usesound);
11050
11051
4/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 49 times.
106 if(dir==up || dir==right)
11052 57 ++blowcnt;
11053 else
11054 49 --blowcnt;
11055
11056 106 int sfx_count = 0;
11057
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 19906 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19910 times.
✓ Branch 6 taken 19800 times.
✓ Branch 7 taken 114 times.
19906 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11058 {
11059 19800 sfx_count += 1;
11060 19800 advanceframe(true);
11061
11062
1/2
✓ Branch 0 taken 19800 times.
✗ Branch 1 not taken.
19800 if(Quit)
11063 return false;
11064 }
11065
11066
9/14
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 110 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 114 times.
✓ Branch 13 taken 4 times.
114 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11067
11068
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11069 9 didstuff |= did_whistle;
11070
11071
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 103 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
114 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11072 11 return false;
11073
11074
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 99 times.
103 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11075
11076
4/4
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 77 times.
103 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11077
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 || (tmpscr->flags7&fWHISTLEPAL))
11078 {
11079 26 whistleclk=0; // signal to start drying lake or doing other stuff
11080 26 }
11081 else
11082 {
11083 77 int32_t where = itm.misc1;
11084
11085
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(where>right) where=dir^1;
11086
11087
5/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 42 times.
119 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11088
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
46 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11089
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 42 times.
✗ Branch 11 not taken.
84 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11090
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 42 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 42 times.
✗ Branch 9 not taken.
42 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11091
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 (zfix)0,
11092 wWind,
11093 0, //type
11094 0,
11095 42 where,
11096
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11097
11098 73 whistleitem=itemid;
11099 }
11100
11101 99 ret = false;
11102 }
11103 99 break;
11104
11105 case itype_bomb:
11106 {
11107 //Remote detonation
11108
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 459 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 463 times.
464 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11109 {
11110 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11111
11112
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11113 {
11114 //If this ever needs a version check, in the future. -z
11115 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11116 {
11117 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11118 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11119 }
11120 ew->misc=50;
11121 ew->clk=ew->misc-3;
11122 ew->id=wBomb;
11123 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11124 }
11125
11126 1 deselectbombs(false);
11127 1 return false;
11128 }
11129
11130
2/4
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 463 times.
463 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11131 {
11132 return item_error();
11133 }
11134
11135 463 paymagiccost(itemid);
11136
11137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if(itm.misc1>0) // If not remote bombs
11138 463 deselectbombs(false);
11139
11140
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 412 times.
463 if(isdungeon())
11141 {
11142
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 36 times.
412 wy=zc_max(wy,16);
11143 412 }
11144
11145
4/8
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 463 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 463 times.
✗ Branch 7 not taken.
926 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11146
2/4
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 463 times.
✗ Branch 3 not taken.
463 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11147 463 sfx(WAV_PLACE,pan(wx));
11148 }
11149 463 break;
11150
11151 case itype_sbomb:
11152 {
11153 //Remote detonation
11154
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11155 {
11156 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11157
11158 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11159 {
11160 ew->misc=50;
11161 ew->clk=ew->misc-3;
11162 ew->id=wSBomb;
11163 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11164 }
11165
11166 deselectbombs(true);
11167 return false;
11168 }
11169
11170
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11171 {
11172 return item_error();
11173 }
11174
11175 12 paymagiccost(itemid);
11176
11177
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itm.misc1>0) // If not remote bombs
11178 12 deselectbombs(true);
11179
11180
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true));
11181 12 sfx(WAV_PLACE,pan(wx));
11182 }
11183 12 break;
11184
11185 case itype_wand:
11186 {
11187
2/2
✓ Branch 0 taken 363 times.
✓ Branch 1 taken 835 times.
1198 if(Lwpns.idCount(wMagic))
11188 {
11189 363 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11190 363 return false;
11191 }
11192
11193 835 int32_t bookid = current_item_id(itype_book);
11194
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 437 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
835 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11195
11196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
835 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11197 {
11198 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11199 return false;
11200 }
11201
11202
3/6
✓ Branch 0 taken 835 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 835 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 835 times.
✗ Branch 5 not taken.
835 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11203 {
11204 return item_error();
11205 }
11206
11207
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 3 times.
835 if(Lwpns.idCount(wBeam))
11208 3 Lwpns.del(Lwpns.idFirst(wBeam));
11209
11210 int32_t type, pow;
11211
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 663 times.
835 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11212 {
11213
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 74 times.
172 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11214
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 74 times.
172 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11215 172 }
11216 else
11217 {
11218
3/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
663 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11219
3/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
663 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11220 }
11221
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1670 times.
✓ Branch 4 taken 835 times.
✓ Branch 5 taken 835 times.
1670 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
1670 if(dir!=(i^1))
11223 {
11224
5/10
✓ Branch 0 taken 835 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 835 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 835 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 835 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 835 times.
✗ Branch 9 not taken.
835 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11225
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 398 times.
835 if(paybook)
11226 398 magic->linkedItem = bookid;
11227 //magic->dir = this->dir; //Save player dir for special weapons.
11228 835 Lwpns.add(magic);
11229 835 }
11230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
835 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11231 835 paymagiccost(itemid);
11232 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11233
11234
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 398 times.
835 if(paybook)
11235 398 paymagiccost(current_item_id(itype_book));
11236
11237
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 437 times.
835 if(bookid != -1)
11238 {
11239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11240 {
11241 sfx(itemsbuf[bookid].misc2,pan(wx));
11242 }
11243 else
11244 {
11245 398 sfx(itm.usesound,pan(wx));
11246 }
11247 398 }
11248 else
11249 437 sfx(itm.usesound,pan(wx));
11250 }
11251 /*
11252 // Fireball Wand
11253 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11254 switch (dir)
11255 {
11256 case up:
11257 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11258 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11259 break;
11260 case down:
11261 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11262 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11263 break;
11264 case left:
11265 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11266 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11267 break;
11268 case right:
11269 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11270 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11271 break;
11272 }
11273 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11274 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11275 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11276 */
11277 835 break;
11278
11279 case itype_sword:
11280 {
11281
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8937 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8937 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11282 {
11283 return item_error();
11284 }
11285
11286
4/4
✓ Branch 0 taken 1760 times.
✓ Branch 1 taken 7177 times.
✓ Branch 2 taken 1760 times.
✓ Branch 3 taken 7177 times.
8937 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11287 {
11288 1760 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11289 1760 return false;
11290 }
11291
11292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7177 times.
7177 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11293 7177 paymagiccost(itemid);
11294 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11295 float temppower;
11296
11297
1/2
✓ Branch 0 taken 7177 times.
✗ Branch 1 not taken.
7177 if(itm.flags & ITEM_FLAG2)
11298 {
11299 7177 temppower=game->get_hero_dmgmult()*itm.power;
11300 7177 temppower=temppower*itm.misc2;
11301 7177 temppower=temppower/100;
11302 7177 }
11303 else
11304 {
11305 temppower = game->get_hero_dmgmult()*itm.misc2;
11306 }
11307
11308 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11309 //Add weapon script to sword beams.
11310
5/10
✓ Branch 0 taken 7177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7177 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7177 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7177 times.
✗ Branch 9 not taken.
7177 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11311 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11312 //w->weaponscript = itm.weaponscript;
11313 //w->canrunscript = 0;
11314 7177 sfx(WAV_BEAM,pan(wx));
11315 }
11316 7177 break;
11317
11318 case itype_candle:
11319 {
11320 896 int32_t countid = itemid;
11321
2/2
✓ Branch 0 taken 876 times.
✓ Branch 1 taken 20 times.
896 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11322 876 countid = -itype_candle;
11323
5/6
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 887 times.
896 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11324 {
11325 9 return false;
11326 }
11327
11328
3/4
✓ Branch 0 taken 887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 824 times.
887 if(Lwpns.idCount(wFire) >= (itm.misc3 < 1 ? 2 : itm.misc3))
11329 {
11330 63 return false;
11331 }
11332
11333
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11334 {
11335 return item_error();
11336 }
11337
11338 824 paymagiccost(itemid);
11339
11340
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 92 times.
824 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11341
11342
4/8
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 824 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 824 times.
✗ Branch 7 not taken.
1648 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11343 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11344 824 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11345
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11346 824 sfx(itm.usesound,pan(wx));
11347 824 attack=wFire;
11348 }
11349 824 break;
11350
11351 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11352 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11353 {
11354 int32_t wtype = wScript1 + (itm.family-itype_script1);
11355 if(Lwpns.idCount(wtype))
11356 return false;
11357
11358 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11359 {
11360 return item_error();
11361 }
11362
11363 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11364 paymagiccost(itemid);
11365
11366 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11367 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11368 sfx(itm.usesound,pan(wx));
11369 }
11370 break;
11371
11372 case itype_icerod:
11373 {
11374 if(Lwpns.idCount(wIce))
11375 return false;
11376
11377 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11378 {
11379 return item_error();
11380 }
11381
11382 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11383 paymagiccost(itemid);
11384
11385 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11386 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11387 sfx(itm.usesound,pan(wx));
11388 }
11389 break;
11390
11391 case itype_arrow:
11392 {
11393
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 361 times.
378 if(Lwpns.idCount(wArrow) > itm.misc2)
11394 17 return false;
11395
11396
2/4
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 361 times.
361 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11397 {
11398 return item_error();
11399 }
11400
11401 361 paymagiccost(itemid);
11402
11403
6/12
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 361 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 361 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 361 times.
✗ Branch 11 not taken.
361 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11404 361 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11405 361 sfx(itm.usesound,pan(wx));
11406 }
11407 361 break;
11408
11409 case itype_bait:
11410 {
11411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11412 return false;
11413
11414
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!checkbunny(itemid))
11415 return item_error();
11416
11417
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
11418
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
11419
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
11420
11421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!grumble && (itm.flags & ITEM_FLAG2))
11422 return item_error(); //Only usable for grumble rooms
11423
11424
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(checkcost && !checkmagiccost(itemid))
11425 return item_error();
11426
11427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(paycost)
11428 6 paymagiccost(itemid);
11429 6 sfx(itm.usesound,pan(wx));
11430
11431
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(grumble)
11432 {
11433
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
11434 6 fadeclk=66;
11435 6 dismissmsg();
11436 6 clear_bitmap(pricesdisplaybuf);
11437 6 set_clip_state(pricesdisplaybuf, 1);
11438 // putscr(scrollbuf,0,0,tmpscr);
11439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
11441 {
11442 6 removeItemsOfFamily(game,itemsbuf,itype_bait);
11443 6 verifyBothWeapons();
11444 6 }
11445 6 sfx(tmpscr->secretsfx);
11446 6 return false;
11447 }
11448
11449 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11450 break;
11451 }
11452
11453 case itype_brang:
11454 {
11455
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 5136 times.
5356 if(Lwpns.idCount(wBrang) > itm.misc2)
11456 220 return false;
11457
11458
2/4
✓ Branch 0 taken 5136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5136 times.
5136 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11459 {
11460 return item_error();
11461 }
11462
11463 5136 paymagiccost(itemid);
11464 5136 current_item_power(itype_brang);
11465
6/12
✓ Branch 0 taken 5136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5136 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5136 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5136 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5136 times.
✗ Branch 11 not taken.
5136 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11466 }
11467 5136 break;
11468
11469 case itype_hookshot:
11470 case itype_switchhook:
11471 {
11472
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(inlikelike || Lwpns.idCount(wHookshot))
11473 return false;
11474
11475
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11476 {
11477 return item_error();
11478 }
11479 33 bool sw = itm.family == itype_switchhook;
11480
11481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if(sw && (itm.flags&ITEM_FLAG8))
11482 switchhook_cost_item = itemid;
11483 33 else paymagiccost(itemid);
11484
11485 33 bool use_hookshot=true;
11486 33 bool hit_hs = false, hit_solid = false, insta_switch = false;
11487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11488 33 int32_t cpos = -1, ffcpos = -1;
11489
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 33 times.
66 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11490 {
11491
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13 times.
33 if(dir==up)
11492 {
11493
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11494 hit_hs = true;
11495 13 }
11496
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 else if(dir==down)
11497 {
11498
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11499 hit_hs = true;
11500 4 }
11501
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 else if(dir==left)
11502 {
11503
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11504 hit_hs = true;
11505 3 }
11506
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 else if(dir==right)
11507 {
11508
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11509 hit_hs = true;
11510 13 }
11511 //Diagonal Hookshot (6)
11512 else if(dir==r_down)
11513 {
11514 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11515 hit_hs = true;
11516 }
11517 else if(dir==l_down)
11518 {
11519 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11520 hit_hs = true;
11521 }
11522 else if(dir==r_up)
11523 {
11524 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11525 hit_hs = true;
11526 }
11527 else if(dir==l_up)
11528 {
11529 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11530 hit_hs = true;
11531 }
11532 33 }
11533
7/10
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11534 hit_solid = true;
11535
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(hit_hs)
11536 {
11537 if(sw)
11538 insta_switch = true; //switch immediately
11539 else use_hookshot = false; //No hooking against grabbable
11540 }
11541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if(hit_solid && !insta_switch)
11542 use_hookshot = false;
11543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(use_hookshot)
11544 {
11545 33 int32_t hookitem = itm.fam_type;
11546 33 int32_t hookpower = itm.power;
11547 33 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11548
11549
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!Lwpns.has_space())
11550 {
11551 Lwpns.del(0);
11552 }
11553
11554
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!Lwpns.has_space(2))
11555 {
11556 Lwpns.del(0);
11557 }
11558
11559
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33 switch(dir)
11560 {
11561 case up:
11562 {
11563 13 hookshot_used=true;
11564 13 hs_switcher = sw;
11565
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11566
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11567 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11568
5/10
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
26 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11569
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11570 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11571 13 hs_startx=wx;
11572 13 hs_starty=wy-4;
11573 }
11574 13 break;
11575
11576 case down:
11577 {
11578 4 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11579 4 hookshot_used=true;
11580 4 hs_switcher = sw;
11581
5/10
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
8 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11582
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11583 4 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11584
5/10
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
8 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11585
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11586 4 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11587 4 hs_startx=wx;
11588 4 hs_starty=wy;
11589 }
11590 4 break;
11591
11592 case left:
11593 {
11594 3 hookshot_used=true;
11595 3 hs_switcher = sw;
11596
4/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11597
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11598 3 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11599
4/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11600
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11601 3 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11602 3 hs_startx=wx-4;
11603 3 hs_starty=wy;
11604 }
11605 3 break;
11606
11607 case right:
11608 {
11609 13 hookshot_used=true;
11610 13 hs_switcher = sw;
11611
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11612
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11613 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11614
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11615
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11616 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11617 13 hs_startx=wx+4;
11618 13 hs_starty=wy;
11619 }
11620 13 break;
11621 //Diagonal Hookshot (7)
11622 case r_down:
11623 {
11624 hookshot_used=true;
11625 hs_switcher = sw;
11626 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11627 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11628 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11629 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11630 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11631 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11632 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11633 hs_startx=wx+4;
11634 hs_starty=wy;
11635 }
11636 break;
11637
11638 case r_up:
11639 {
11640 hookshot_used=true;
11641 hs_switcher = sw;
11642 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11643 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11644 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11645 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11646 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11647 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11648 hs_startx=wx+4;
11649 hs_starty=wy;
11650 }
11651 break;
11652
11653 case l_down:
11654 {
11655 hookshot_used=true;
11656 hs_switcher = sw;
11657 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11658 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11659 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11660 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11661 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11662 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11663 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11664 hs_startx=wx+4;
11665 hs_starty=wy;
11666 }
11667 break;
11668
11669 case l_up:
11670 {
11671 hookshot_used=true;
11672 hs_switcher = sw;
11673 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11674 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11675 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11676 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11677 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11678 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11679 hs_startx=wx+4;
11680 hs_starty=wy;
11681 }
11682 break;
11683 }
11684 33 hookshot_frozen=true;
11685 33 }
11686
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(insta_switch)
11687 {
11688 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11689 if (cpos > -1) hooked_combopos = cpos;
11690 if (ffcpos > -1)
11691 {
11692 switching_object = &(tmpscr->ffcs[ffcpos]);
11693 switching_object->switch_hooked = true;
11694 }
11695 w->misc=2;
11696 w->step=0;
11697 doSwitchHook(itm.misc5);
11698 if(itm.usesound2)
11699 sfx(itm.usesound2,pan(int32_t(x)));
11700 else if(QMisc.miscsfx[sfxSWITCHED])
11701 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11702 stop_sfx(itm.usesound);
11703 }
11704 }
11705 33 break;
11706
11707 case itype_dinsfire:
11708 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11709 return false;
11710
11711 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11712 {
11713 return item_error();
11714 }
11715
11716 paymagiccost(itemid);
11717 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11718 else {action=casting; FFCore.setHeroAction(casting);}
11719 magicitem=itemid;
11720 break;
11721
11722 case itype_faroreswind:
11723 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11724 return false;
11725
11726 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11727 {
11728 return item_error();
11729 }
11730
11731 paymagiccost(itemid);
11732 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11733 else {action=casting; FFCore.setHeroAction(casting);}
11734 magicitem=itemid;
11735 break;
11736
11737 case itype_nayruslove:
11738 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11739 return false;
11740
11741 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11742 {
11743 return item_error();
11744 }
11745
11746 paymagiccost(itemid);
11747 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11748 else {action=casting; FFCore.setHeroAction(casting);}
11749 magicitem=itemid;
11750 break;
11751
11752 case itype_cbyrna:
11753 {
11754 //Beams already deployed
11755 if(Lwpns.idCount(wCByrna))
11756 {
11757 stopCaneOfByrna();
11758 return false;
11759 }
11760
11761 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11762 {
11763 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11764 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11765 return false;
11766 }
11767
11768 paymagiccost(itemid);
11769 last_cane_of_byrna_item_id = itemid;
11770 //zprint("itm.misc3: %d\n", itm.misc3);
11771 for(int32_t i=0; i<itm.misc3; i++)
11772 {
11773 //byrna weapons are added here
11774 //space them apart
11775 //zprint("Added byrna weapon %d.\n", i);
11776 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11777 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11778 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11779 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11780 //wx += cos(2 * PI / (itm.misc3-i));
11781 //wy += sin(2 * PI / (itm.misc3-i));
11782 }
11783 if(!(Lwpns.idCount(wCByrna)))
11784 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11785 }
11786 break;
11787
11788 case itype_clock:
11789 {
11790 ret = false;
11791 if(!(itm.flags & ITEM_FLAG1))
11792 break; //Passive clock, don't use
11793 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11794 break;
11795 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11796 {
11797 return item_error();
11798 }
11799
11800 paymagiccost(itemid);
11801
11802 setClock(watch=true);
11803
11804 for(int32_t i=0; i<eMAXGUYS; i++)
11805 clock_zoras[i]=0;
11806
11807 clockclk=itm.misc1;
11808 sfx(itm.usesound);
11809 break;
11810 }
11811 case itype_killem:
11812 {
11813 ret = false;
11814 if(!(itm.flags & ITEM_FLAG1))
11815 break; //Passive killemall, don't use
11816
11817 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11818 || !can_kill_em_all()) //No enemies onscreen
11819 {
11820 return item_error();
11821 }
11822
11823 paymagiccost(itemid);
11824
11825 kill_em_all();
11826 sfx(itm.usesound);
11827 break;
11828 }
11829 case itype_refill:
11830 {
11831 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11832 {
11833 return item_error();
11834 }
11835
11836 bool did_something = false;
11837
11838 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
11839 {
11840 if(swordclk)
11841 did_something = true;
11842 swordclk = 0;
11843 verifyAWpn();
11844 }
11845 for(auto q = 0; q < 5; ++q)
11846 {
11847 auto ctr = itm.misc(q);
11848 if(unsigned(ctr) >= MAX_COUNTERS)
11849 continue;
11850 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
11851 if(!amnt) continue;
11852 bool gradual = itm.flags & ITEM_FLAG2;
11853 if(amnt > 0)
11854 {
11855 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
11856 {
11857 //Can't *do* anything... skip
11858 continue;
11859 }
11860 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
11861 {
11862 //Can't do anything unless affecting dcounter
11863 gradual = true;
11864 }
11865 }
11866 else //Negative
11867 {
11868 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
11869 {
11870 //Can't *do* anything... skip
11871 continue;
11872 }
11873 if(game->get_counter(ctr) <= 0)
11874 {
11875 //Can't do anything unless affecting dcounter
11876 gradual = true;
11877 }
11878 }
11879 did_something = true;
11880 if(gradual) //Gradual
11881 {
11882 game->change_dcounter(amnt, ctr);
11883 }
11884 else
11885 {
11886 game->change_counter(amnt, ctr);
11887 }
11888 }
11889 if(!did_something)
11890 {
11891 return item_error();
11892 }
11893 paymagiccost(itemid);
11894 sfx(itm.usesound);
11895 ret = false;
11896 break;
11897 }
11898
11899 default:
11900 550 ret = false;
11901 550 }
11902
11903
2/2
✓ Branch 0 taken 15554 times.
✓ Branch 1 taken 20 times.
15574 if(itm.flags & ITEM_DOWNGRADE)
11904 {
11905 20 game->set_item(itemid,false);
11906
11907 // Maybe Item Override has allowed the same item in both slots?
11908
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Bwpn == itemid)
11909 {
11910 Bwpn = 0;
11911 game->forced_bwpn = -1;
11912 verifyBWpn();
11913 }
11914
11915
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Awpn == itemid)
11916 {
11917 Awpn = 0;
11918 game->forced_awpn = -1;
11919 verifyAWpn();
11920 }
11921
11922
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Xwpn == itemid)
11923 {
11924 Xwpn = 0;
11925 game->forced_xwpn = -1;
11926 verifyXWpn();
11927 }
11928
11929
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Ywpn == itemid)
11930 {
11931 Ywpn = 0;
11932 game->forced_ywpn = -1;
11933 verifyYWpn();
11934 }
11935 20 }
11936
11937 15574 return ret;
11938 18066 }
11939
11940
11941 593483 bool HeroClass::doattack()
11942 {
11943 //int32_t s = BSZ ? 0 : 11;
11944 593483 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
11945
11946
3/4
✓ Branch 0 taken 31486 times.
✓ Branch 1 taken 561997 times.
✓ Branch 2 taken 31486 times.
✗ Branch 3 not taken.
593483 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
11947
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 593483 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
593483 if(attack==wBugNet && bugnetid!=-1)
11948 {
11949 if(++attackclk >= NET_CLK_TOTAL)
11950 return false;
11951
11952 return true;
11953 }
11954
11955 // Abort attack if attackclk has run out and:
11956 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
11957 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
11958
11959
6/6
✓ Branch 0 taken 37021 times.
✓ Branch 1 taken 556462 times.
✓ Branch 2 taken 35559 times.
✓ Branch 3 taken 1462 times.
✓ Branch 4 taken 2287 times.
✓ Branch 5 taken 3091 times.
598861 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
11960
12/12
✓ Branch 0 taken 30013 times.
✓ Branch 1 taken 5546 times.
✓ Branch 2 taken 3567 times.
✓ Branch 3 taken 26446 times.
✓ Branch 4 taken 30796 times.
✓ Branch 5 taken 4763 times.
✓ Branch 6 taken 30181 times.
✓ Branch 7 taken 615 times.
✓ Branch 8 taken 3566 times.
✓ Branch 9 taken 1812 times.
✓ Branch 10 taken 2264 times.
✓ Branch 11 taken 1302 times.
35559 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
11961 {
11962 33272 tapping=false;
11963 33272 return false;
11964 }
11965
11966
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 560116 times.
560211 if(attackclk>29)
11967 {
11968 95 tapping=false;
11969 95 return false;
11970 }
11971
11972
4/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 530617 times.
✓ Branch 2 taken 27699 times.
✓ Branch 3 taken 1800 times.
560116 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
11973
3/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 530617 times.
✓ Branch 2 taken 29499 times.
✗ Branch 3 not taken.
560116 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
11974 // An attack can be "walked out-of" after 8 frames, unless it's:
11975 // * a sword stab
11976 // * a hammer pound
11977 // * a wand thrust
11978 // * a candle thrust
11979 // * a cane thrust
11980 // In which case it should continue.
11981
8/8
✓ Branch 0 taken 24695 times.
✓ Branch 1 taken 535421 times.
✓ Branch 2 taken 63191 times.
✓ Branch 3 taken 38496 times.
✓ Branch 4 taken 507073 times.
✓ Branch 5 taken 66844 times.
✓ Branch 6 taken 102653 times.
✓ Branch 7 taken 404420 times.
660170 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
11982
5/6
✓ Branch 0 taken 100054 times.
✓ Branch 1 taken 2599 times.
✓ Branch 2 taken 10812 times.
✓ Branch 3 taken 89242 times.
✓ Branch 4 taken 10812 times.
✗ Branch 5 not taken.
102653 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
11983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 89242 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
100054 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
11984
2/2
✓ Branch 0 taken 100054 times.
✓ Branch 1 taken 10812 times.
89242 && (attack != wBugNet) && attackclk>7))
11985 {
11986
8/8
✓ Branch 0 taken 35375 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 34180 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 32561 times.
✓ Branch 5 taken 1619 times.
✓ Branch 6 taken 1503 times.
✓ Branch 7 taken 31058 times.
163245 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
11987 {
11988 5805 lstep = s;
11989 5805 return false;
11990 }
11991 31058 }
11992
11993
2/2
✓ Branch 0 taken 1916 times.
✓ Branch 1 taken 524629 times.
526545 if(charging==0)
11994 {
11995 524629 lstep=0;
11996 524629 }
11997
11998 // Work out the sword charge-up delay
11999 526545 int32_t magiccharge = 192, normalcharge = 64;
12000 526545 int32_t itemid = current_item_id(itype_chargering);
12001
12002
2/2
✓ Branch 0 taken 488235 times.
✓ Branch 1 taken 38310 times.
526545 if(itemid>=0)
12003 {
12004 38310 normalcharge = itemsbuf[itemid].misc1;
12005 38310 magiccharge = itemsbuf[itemid].misc2;
12006 38310 }
12007
12008 526545 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12009
12010 526545 bool doCharge=true;
12011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 526545 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
526545 if(z!=0 && fakez != 0)
12012 doCharge=false;
12013
2/2
✓ Branch 0 taken 404420 times.
✓ Branch 1 taken 122125 times.
526545 if(attack==wSword)
12014 {
12015
4/4
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 402759 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1637 times.
404420 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12016 402783 doCharge=false;
12017
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 1220 times.
1637 else if(charging<=normalcharge)
12018 {
12019
3/6
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1220 times.
✗ Branch 5 not taken.
1220 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12020 doCharge=false;
12021 1220 }
12022 404420 }
12023
2/2
✓ Branch 0 taken 2599 times.
✓ Branch 1 taken 119526 times.
122125 else if(attack==wHammer)
12024 {
12025
4/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 2505 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 8 times.
2599 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12026 2591 doCharge=false;
12027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(charging<=normalcharge)
12028 {
12029
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
8 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12030 doCharge=false;
12031 8 }
12032 2599 }
12033 else
12034 119526 doCharge=false;
12035
12036 // Now work out the magic cost
12037 526545 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12038
12039 // charging up weapon...
12040 //
12041
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 524900 times.
526545 if(doCharge)
12042 {
12043 // Increase charging while holding down button.
12044
3/4
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1517 times.
1645 if(spins==0 && charging<magiccharge)
12045 1517 charging++;
12046
12047 // Once a charging threshold is reached, play the sound.
12048
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1636 times.
1645 if(charging==normalcharge)
12049 {
12050 9 paymagiccost(itemid); //!DIMITODO: Can this underflow or even just do it even if you don't have magic?
12051 9 sfx(WAV_ZN1CHARGE,pan(x.getInt()));
12052 9 }
12053
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 3 times.
1636 else if(charging==magiccharge)
12054 {
12055 3 itemid = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12056
12057
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(itemid>-1 && checkbunny(itemid) && checkmagiccost(itemid))
12058 {
12059 3 paymagiccost(itemid);
12060 3 charging++; // charging>magiccharge signifies a successful supercharge.
12061 3 sfx(WAV_ZN1CHARGE2,pan(x.getInt()));
12062 3 }
12063 3 }
12064 1645 }
12065
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 524900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
524900 else if(attack==wCByrna && byrnaid!=-1)
12066 {
12067 if(!(itemsbuf[byrnaid].wpn))
12068 {
12069 attack = wNone;
12070 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12071 }
12072
12073 bool beamcount = false;
12074
12075 for(int32_t i=0; i<Lwpns.Count(); i++)
12076 {
12077 weapon *w = ((weapon*)Lwpns.spr(i));
12078
12079 if(w->id==wCByrna)
12080 {
12081 beamcount = true;
12082 break;
12083 }
12084 }
12085
12086 // If beams already deployed, remove them
12087 if(!attackclk && beamcount)
12088 {
12089 return startwpn(attackid); // Remove beams instantly
12090 }
12091
12092 // Otherwise, continue
12093 ++attackclk;
12094 }
12095 else
12096 {
12097 524900 ++attackclk;
12098
12099
6/6
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 524742 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 133 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 14 times.
524900 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12100 {
12101 14 ++attackclk; // Won't continue charging
12102 14 charging=0;
12103 14 }
12104
12105 // Faster if spinning.
12106
2/2
✓ Branch 0 taken 524308 times.
✓ Branch 1 taken 592 times.
524900 if(spins>0)
12107 592 ++attackclk;
12108
12109 // Even faster if hurricane spinning.
12110
2/2
✓ Branch 0 taken 524468 times.
✓ Branch 1 taken 432 times.
524900 if(spins>5)
12111 432 attackclk+=2;
12112
12113 // If at a charging threshold, do a charged attack.
12114
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 524786 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✓ Branch 5 taken 8 times.
524900 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12115 {
12116
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(attack==wSword)
12117 {
12118
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 spins=(charging>magiccharge ? (itemsbuf[current_item_id(itype_spinscroll2)].misc1*4)-3
12119 5 : (itemsbuf[current_item_id(itype_spinscroll)].misc1*4)+1);
12120 8 attackclk=1;
12121 8 sfx(itemsbuf[current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
12122 8 }
12123 /*
12124 else if(attack==wWand)
12125 {
12126 //Not reachable.. yet
12127 spins=1;
12128 }
12129 */
12130 else if(attack==wHammer && sideviewhammerpound())
12131 {
12132 spins=1; //signifies the quake hammer
12133 bool super = (charging>magiccharge && current_item(itype_quakescroll2));
12134 sfx(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].usesound,pan(x.getInt()));
12135 quakeclk=(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc1);
12136
12137 // general area stun
12138 for(int32_t i=0; i<GuyCount(); i++)
12139 {
12140 if(!isflier(GuyID(i)))
12141 {
12142 StunGuy(i,(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc2)-
12143 distance(x,y,GuyX(i),GuyY(i)));
12144 }
12145 }
12146 }
12147 8 }
12148
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 524777 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 48 times.
524892 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12149 48 charging++;
12150
12151
7/8
✓ Branch 0 taken 10603 times.
✓ Branch 1 taken 514297 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 514297 times.
✓ Branch 4 taken 16782 times.
✓ Branch 5 taken 497515 times.
✓ Branch 6 taken 365728 times.
✓ Branch 7 taken 159172 times.
524900 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12152 159172 charging=0;
12153
12154
2/2
✓ Branch 0 taken 523760 times.
✓ Branch 1 taken 1140 times.
524900 if(attackclk>=SWORDCHARGEFRAME)
12155 1140 tapping = false;
12156 }
12157
12158
6/8
✓ Branch 0 taken 41321 times.
✓ Branch 1 taken 485224 times.
✓ Branch 2 taken 904 times.
✓ Branch 3 taken 40417 times.
✓ Branch 4 taken 904 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 904 times.
526545 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12159 {
12160 904 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12161 }
12162
12163 525641 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12164
12165
10/12
✓ Branch 0 taken 491973 times.
✓ Branch 1 taken 33668 times.
✓ Branch 2 taken 37813 times.
✓ Branch 3 taken 454160 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 37781 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 20 times.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
525641 if(attackclk==13 || (attackclk==7 && spins>1 && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12166 {
12167
12168
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 31677 times.
✓ Branch 2 taken 578 times.
✓ Branch 3 taken 1425 times.
33680 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12169
2/2
✓ Branch 0 taken 33662 times.
✓ Branch 1 taken 18 times.
33680 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12170
12171
4/4
✓ Branch 0 taken 33662 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 2469 times.
✓ Branch 3 taken 31193 times.
33680 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12172 {
12173 31193 templife=templife*game->get_maxlife();
12174 31193 templife=templife/100;
12175 31193 }
12176 else
12177 {
12178 2487 templife*=game->get_hp_per_heart();
12179 }
12180
12181
2/2
✓ Branch 0 taken 17178 times.
✓ Branch 1 taken 16502 times.
33680 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12182 33680 int32_t perilid = current_item_id(itype_perilscroll);
12183
3/4
✓ Branch 0 taken 1592 times.
✓ Branch 1 taken 32088 times.
✓ Branch 2 taken 1592 times.
✗ Branch 3 not taken.
33681 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12184
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1591 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1592 && checkbunny(perilid) && checkmagiccost(perilid)
12185 // Must actually be able to shoot sword beams
12186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12187
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12188
12189
4/4
✓ Branch 0 taken 27856 times.
✓ Branch 1 taken 5824 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 27837 times.
33680 if(attack==wSword && !tapping)
12190 {
12191
4/4
✓ Branch 0 taken 27836 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8949 times.
✓ Branch 3 taken 18887 times.
27837 if(perilbeam || normalbeam)
12192 {
12193
1/2
✓ Branch 0 taken 8950 times.
✗ Branch 1 not taken.
8950 if(attackclk==7)
12194 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12195
12196
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8949 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
8950 if(perilbeam && !normalbeam)
12197 1 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12198
12199 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12200 // a way to make the peril/cross beam item's power stat influence the strength
12201 // of the peril/cross beam...
12202 8950 startwpn(attackid);
12203 8950 }
12204 18887 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12205 27837 }
12206
12207
2/2
✓ Branch 0 taken 32482 times.
✓ Branch 1 taken 1198 times.
33680 if(attack==wWand)
12208 1198 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12209
12210
4/6
✓ Branch 0 taken 637 times.
✓ Branch 1 taken 33043 times.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 637 times.
✗ Branch 5 not taken.
33680 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12211 startwpn(attackid);
12212
12213
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 33680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
33680 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12214 startwpn(attackid);
12215 33680 }
12216
12217
2/2
✓ Branch 0 taken 492351 times.
✓ Branch 1 taken 33290 times.
525641 if(attackclk==14)
12218 33290 lstep = s;
12219
12220 525641 return true;
12221 565717 }
12222
12223 6971934 bool HeroClass::can_attack()
12224 {
12225
4/4
✓ Branch 0 taken 6810436 times.
✓ Branch 1 taken 161498 times.
✓ Branch 2 taken 4744670 times.
✓ Branch 3 taken 2065766 times.
6971934 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12226
4/6
✓ Branch 0 taken 6971934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6929876 times.
✓ Branch 3 taken 42058 times.
✓ Branch 4 taken 6929876 times.
✗ Branch 5 not taken.
7465568 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12227
5/8
✓ Branch 0 taken 6929876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6929876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6929876 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6928180 times.
✓ Branch 7 taken 1696 times.
6929876 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12228
3/4
✓ Branch 0 taken 6928180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5848012 times.
✓ Branch 3 taken 1080168 times.
6928180 || ((action==attacking||action==sideswimattacking)
12229
2/2
✓ Branch 0 taken 246824 times.
✓ Branch 1 taken 6681356 times.
6928180 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12230
2/2
✓ Branch 0 taken 6928166 times.
✓ Branch 1 taken 246810 times.
6928180 && charging!=0))
12231 {
12232 537388 return false;
12233 }
12234
12235 6928166 int32_t r = (isdungeon()) ? 16 : 0;
12236 6928166 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12237
12238
4/5
✓ Branch 0 taken 2992278 times.
✓ Branch 1 taken 3935888 times.
✓ Branch 2 taken 1700898 times.
✓ Branch 3 taken 2234990 times.
✗ Branch 4 not taken.
6928166 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12239 {
12240 case up:
12241 case down:
12242
2/2
✓ Branch 0 taken 1650906 times.
✓ Branch 1 taken 49992 times.
1700898 return !(y<(r2+r) || y>(160-r-r2));
12243
12244 case left:
12245 case right:
12246
2/2
✓ Branch 0 taken 2184636 times.
✓ Branch 1 taken 50354 times.
2234990 return !(x<(r2+r) || x>(240-r-r2));
12247 }
12248
12249 2992278 return true;
12250 7465554 }
12251
12252 2535 bool isRaftFlag(int32_t flag)
12253 {
12254
4/4
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 1190 times.
2535 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12255 }
12256
12257 3505592 void handle_lens_triggers(int32_t l_id)
12258 {
12259
2/2
✓ Branch 0 taken 3499561 times.
✓ Branch 1 taken 6031 times.
3505592 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12260
2/2
✓ Branch 0 taken 3505592 times.
✓ Branch 1 taken 24539144 times.
28044736 for(auto layer = 0; layer < 7; ++layer)
12261 {
12262 24539144 mapscr* tmp = FFCore.tempScreens[layer];
12263
2/2
✓ Branch 0 taken 4318889344 times.
✓ Branch 1 taken 24539144 times.
4343428488 for(auto pos = 0; pos < 176; ++pos)
12264 {
12265 4318889344 newcombo const& cmb = combobuf[tmp->data[pos]];
12266
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4318889344 times.
✓ Branch 2 taken 4318889344 times.
✗ Branch 3 not taken.
4318889344 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12267 4318889344 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12268 {
12269 do_trigger_combo(layer, pos);
12270 }
12271 4318889344 }
12272 24539144 }
12273
2/2
✓ Branch 0 taken 3361884 times.
✓ Branch 1 taken 143708 times.
3505592 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12274 {
12275 143708 word c = tmpscr->numFFC();
12276
2/2
✓ Branch 0 taken 143708 times.
✓ Branch 1 taken 801302 times.
945010 for(word i=0; i<c; i++)
12277 {
12278 801302 ffcdata& ffc = tmpscr->ffcs[i];
12279 801302 newcombo const& cmb = combobuf[ffc.getData()];
12280
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 801302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 801302 times.
801302 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12281 801302 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12282 {
12283 do_trigger_combo_ffc(i);
12284 break;
12285 }
12286 801302 }
12287 143708 }
12288 3505592 }
12289
12290 3505592 void do_lens()
12291 {
12292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3505592 times.
3505592 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12293 {
12294 do_210_lens();
12295 return;
12296 }
12297
12298 3505592 int32_t wpnPressed = getWpnPressed(itype_lens);
12299
6/6
✓ Branch 0 taken 6028 times.
✓ Branch 1 taken 3499564 times.
✓ Branch 2 taken 374 times.
✓ Branch 3 taken 3499190 times.
✓ Branch 4 taken 383361 times.
✓ Branch 5 taken 3115829 times.
3505592 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12300
2/2
✓ Branch 0 taken 2584949 times.
✓ Branch 1 taken 920643 times.
3505592 if(itemid >= 0)
12301 {
12302
8/10
✓ Branch 0 taken 5125 times.
✓ Branch 1 taken 915518 times.
✓ Branch 2 taken 5125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 674 times.
✓ Branch 5 taken 4451 times.
✓ Branch 6 taken 674 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 508 times.
920643 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12303 {
12304
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 208 times.
508 if(lensid<0)
12305 {
12306 208 lensid=itemid;
12307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(itemsbuf[itemid].family == itype_lens)
12308 208 Hero.setLastLensID(itemid);
12309
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 11 times.
208 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12310 208 }
12311
12312 508 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12313
12314
2/10
✓ Branch 0 taken 508 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 508 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
508 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12315 {
12316 //clear the item script stack for a new script
12317 //itemScriptData[(itemid & 0xFFF)].Clear();
12318 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12319 ri = &(itemScriptData[itemid]);
12320 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12321 ri->Clear();
12322 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12323 item_doscript[itemid] = 1;
12324 itemscriptInitialised[itemid] = 0;
12325 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12326 did_scriptl=true;
12327 }
12328
12329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508 times.
508 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12330 508 else lensclk = 12;
12331 508 }
12332 else
12333 {
12334 920135 did_scriptl=false;
12335
2/2
✓ Branch 0 taken 5523 times.
✓ Branch 1 taken 914612 times.
920135 if(!lensclk)
12336 {
12337
12338
2/2
✓ Branch 0 taken 914407 times.
✓ Branch 1 taken 205 times.
914612 if(lensid>-1)
12339 {
12340 205 lensid=-1;
12341 205 lensclk = 0;
12342
12343
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 10 times.
205 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12344 205 }
12345 914612 }
12346 }
12347 920643 }
12348 3505592 handle_lens_triggers(lensid);
12349 3505592 }
12350 //Add 2.10 version check to call this
12351 void do_210_lens()
12352 {
12353 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12354
12355 if(itemid<0)
12356 return;
12357
12358 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12359 {
12360 if(lensid<0)
12361 {
12362 lensid=itemid;
12363
12364 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12365 }
12366
12367 paymagiccost(itemid, true);
12368
12369 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12370 {
12371 //clear the item script stack for a new script
12372 //itemScriptData[(itemid & 0xFFF)].Clear();
12373 ri = &(itemScriptData[itemid]);
12374 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12375 ri->Clear();
12376 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12377 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12378 item_doscript[itemid] = 1;
12379 itemscriptInitialised[itemid] = 0;
12380 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12381 did_scriptl=true;
12382 }
12383
12384 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12385 else lensclk = 12;
12386 }
12387 else
12388 {
12389 did_scriptl=false;
12390
12391 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12392 {
12393 lensid=-1;
12394 lensclk = 0;
12395
12396 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12397 }
12398 }
12399 }
12400
12401 2455 void HeroClass::do_hopping()
12402 {
12403 2455 do_lens();
12404
12405
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 2385 times.
2455 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12406 //Possible fix for exiting water in diagonal movement. -Z
12407 {
12408 70 int32_t flippers_id = current_item_id(itype_flippers);
12409
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 68 times.
70 if(diveclk>0)
12410 {
12411 2 --diveclk;
12412
2/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12413 {
12414 diveclk = itemsbuf[flippers_id].misc2;
12415 }
12416 2 }
12417
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 else if(DrunkrAbtn())
12418 {
12419 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12420 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12421
12422 if(global_diving==screen_diving)
12423 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12424 }
12425
12426
3/6
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
70 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12427 {
12428 70 SetSwim();
12429 70 hopclk = 0;
12430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!IsSideSwim())
12431 {
12432 70 charging = attackclk = 0;
12433 70 tapping = false;
12434 70 }
12435 70 }
12436 else
12437 {
12438 herostep();
12439
12440 if(!isDiving() || (frame&1))
12441 {
12442 switch(dir)
12443 {
12444 case up:
12445 y -= 1;
12446 break;
12447
12448 case down:
12449 y += 1;
12450 break;
12451
12452 case left:
12453 x -= 1;
12454 break;
12455
12456 case right:
12457 x += 1;
12458 break;
12459 }
12460 }
12461 }
12462 70 }
12463 else // hopping in or out (need to separate the cases...)
12464 {
12465
2/4
✓ Branch 0 taken 2385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2385 times.
2385 if((diagonalMovement||NO_GRIDLOCK))
12466 {
12467 if(hopclk==1) //hopping out
12468 //>= 1 possible fix for getting stuck on land edges.
12469 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12470 {
12471 if(hopdir!=-1) dir=hopdir;
12472
12473 landswim=0;
12474
12475 if(dir==up)
12476 {
12477 herostep();
12478 herostep();
12479 int32_t sidestep=0;
12480
12481 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12482 sidestep=1;
12483 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12484 sidestep=2;
12485
12486 if(sidestep==1) x++;
12487 else if(sidestep==2) x--;
12488 else y--;
12489
12490 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12491 {
12492 hopclk=0;
12493 diveclk=0;
12494 action=none; FFCore.setHeroAction(none);
12495 hopdir=-1;
12496 }
12497 }
12498
12499 if(dir==down)
12500 {
12501 herostep();
12502 herostep();
12503 int32_t sidestep=0;
12504
12505 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12506 sidestep=1;
12507 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12508 sidestep=2;
12509
12510 if(sidestep==1) x++;
12511 else if(sidestep==2) x--;
12512 else y++;
12513
12514 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12515 {
12516 hopclk=0;
12517 diveclk=0;
12518 action=none; FFCore.setHeroAction(none);
12519 hopdir=-1;
12520 }
12521 }
12522
12523 if(dir==left)
12524 {
12525 herostep();
12526 herostep();
12527 int32_t sidestep=0;
12528
12529 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12530 sidestep=1;
12531 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12532 sidestep=2;
12533
12534 if(sidestep==1) y++;
12535 else if(sidestep==2) y--;
12536 else x--;
12537
12538 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12539 {
12540 hopclk=0;
12541 diveclk=0;
12542 action=none; FFCore.setHeroAction(none);
12543 hopdir=-1;
12544 }
12545 }
12546
12547 if(dir==right)
12548 {
12549 herostep();
12550 herostep();
12551 int32_t sidestep=0;
12552
12553 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12554 sidestep=1;
12555 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12556 sidestep=2;
12557
12558 if(sidestep==1) y++;
12559 else if(sidestep==2) y--;
12560 else x++;
12561
12562 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12563 {
12564 hopclk=0;
12565 diveclk=0;
12566 action=none; FFCore.setHeroAction(none);
12567 hopdir=-1;
12568 }
12569 }
12570 }
12571
12572 if(hopclk==2) //hopping in
12573 {
12574 landswim=0;
12575
12576 if(dir==up)
12577 {
12578 herostep();
12579 herostep();
12580 int32_t sidestep=0;
12581
12582 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12583 sidestep=1;
12584 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12585 sidestep=2;
12586
12587 if(sidestep==1) x++;
12588 else if(sidestep==2) x--;
12589 else y--;
12590
12591 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12592 {
12593 hopclk=0xFF;
12594 diveclk=0;
12595 SetSwim();
12596 }
12597 }
12598
12599 if(dir==down)
12600 {
12601 herostep();
12602 herostep();
12603 int32_t sidestep=0;
12604
12605 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12606 sidestep=1;
12607 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12608 sidestep=2;
12609
12610 if(sidestep==1) x++;
12611 else if(sidestep==2) x--;
12612 else y++;
12613
12614 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12615 {
12616 hopclk=0xFF;
12617 diveclk=0;
12618 SetSwim();
12619 if (!IsSideSwim()) reset_swordcharge();
12620 }
12621 }
12622
12623 if(dir==left)
12624 {
12625 herostep();
12626 herostep();
12627 int32_t sidestep=0;
12628
12629 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12630 sidestep=1;
12631 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12632 sidestep=2;
12633
12634 if(sidestep==1) y++;
12635 else if(sidestep==2) y--;
12636 else x--;
12637
12638 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12639 {
12640 hopclk=0xFF;
12641 diveclk=0;
12642 SetSwim();
12643 }
12644 }
12645
12646 if(dir==right)
12647 {
12648 herostep();
12649 herostep();
12650
12651 int32_t sidestep=0;
12652
12653 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12654 sidestep=1;
12655 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12656 sidestep=2;
12657
12658 if(sidestep==1) y++;
12659 else if(sidestep==2) y--;
12660 else x++;
12661
12662 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12663 {
12664 hopclk=0xFF;
12665 diveclk=0;
12666 SetSwim();
12667 }
12668 }
12669 }
12670
12671 }
12672 else
12673 {
12674
7/8
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 1493 times.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 657 times.
✓ Branch 5 taken 235 times.
✓ Branch 6 taken 129 times.
✓ Branch 7 taken 1364 times.
2385 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12675 {
12676 235 action=none; FFCore.setHeroAction(none);
12677 235 hopclk = 0;
12678 235 diveclk = 0;
12679
12680
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 118 times.
235 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12681 {
12682 // hopped in
12683 118 SetSwim();
12684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if (!IsSideSwim()) attackclk = charging = spins = 0;
12685 118 }
12686 235 }
12687 else
12688 {
12689 2150 herostep();
12690 2150 herostep();
12691
12692
2/2
✓ Branch 0 taken 2023 times.
✓ Branch 1 taken 127 times.
2150 if(++hero_count>(16*hero_animation_speed))
12693 127 hero_count=0;
12694
12695 2150 int32_t xofs2 = x.getInt()&15;
12696 2150 int32_t yofs2 = y.getInt()&15;
12697 2150 int32_t s = 1 + (frame&1);
12698
12699
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 764 times.
2150 switch(dir)
12700 {
12701 case up:
12702
3/4
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
278 if(yofs2<3 || yofs2>13) --y;
12703 191 else y-=s;
12704
12705 278 break;
12706
12707 case down:
12708
4/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 360 times.
508 if(yofs2<3 || yofs2>13) ++y;
12709 360 else y+=s;
12710
12711 508 break;
12712
12713 case left:
12714
4/4
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 437 times.
600 if(xofs2<3 || xofs2>13) --x;
12715 437 else x-=s;
12716
12717 600 break;
12718
12719 case right:
12720
4/4
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 540 times.
764 if(xofs2<3 || xofs2>13) ++x;
12721 540 else x+=s;
12722
12723 764 break;
12724 }
12725 }
12726 }
12727 }
12728 2455 }
12729
12730 17170 void HeroClass::do_rafting()
12731 {
12732
12733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 if(toogam)
12734 {
12735 action=none; FFCore.setHeroAction(none);
12736 return;
12737 }
12738
12739 17170 FFCore.setHeroAction(rafting);
12740
12741 17170 do_lens();
12742
12743 17170 herostep();
12744
12745 //Calculate rafting speed
12746 17170 int32_t raft_item = current_item_id(itype_raft);
12747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12748 17170 raft_step = vbound(raft_step, -8, 5);
12749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 if(raft_step < 0) raft_step = 1;
12751 17170 int32_t step_inc = 1 << (raft_step - 1);
12752 // Fix position
12753
1/2
✓ Branch 0 taken 17170 times.
✗ Branch 1 not taken.
17170 if(raft_step > 1)
12754 {
12755 if(x.getInt() & (step_inc-1))
12756 {
12757 x = x.getInt() & ~(step_inc-1);
12758 }
12759 if(y.getInt() & (step_inc-1))
12760 {
12761 y = y.getInt() & ~(step_inc-1);
12762 }
12763 }
12764 // Inc clock, check if we need to move this frame
12765 17170 ++raftclk;
12766
2/4
✓ Branch 0 taken 17170 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17170 times.
17170 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12767
12768
4/4
✓ Branch 0 taken 7795 times.
✓ Branch 1 taken 9375 times.
✓ Branch 2 taken 6514 times.
✓ Branch 3 taken 1281 times.
18446 if(!(x.getInt()&15) && !(y.getInt()&15))
12769 {
12770 // this sections handles switching to raft branches
12771
3/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1264 times.
1281 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12772 {
12773
5/8
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12774 {
12775 3 dir = up;
12776 3 goto skip;
12777 }
12778
12779
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12780 {
12781 dir = down;
12782 goto skip;
12783 }
12784
12785
5/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12786 {
12787 1 dir = left;
12788 1 goto skip;
12789 }
12790
12791
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12792 {
12793 1 dir = right;
12794 1 goto skip;
12795 }
12796 12 }
12797
2/4
✓ Branch 0 taken 1264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1264 times.
1264 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
12798 {
12799 if(dir == left) dir = right;
12800 else if(dir == right) dir = left;
12801 else if(dir == up) dir = down;
12802 else if(dir == down) dir = up;
12803 }
12804
12805
12806
3/4
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 1085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
1276 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
12807 {
12808
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 85 times.
191 if(dir<left) //going up or down
12809 {
12810
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
106 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12811 5 dir=right;
12812
3/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
101 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12813 15 dir=left;
12814
4/4
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 7 times.
86 else if(y>0 && y<160)
12815 {
12816 72 action=none; FFCore.setHeroAction(none);
12817 72 x = x.getInt();
12818 72 y = y.getInt();
12819 72 }
12820 106 }
12821 else //going left or right
12822 {
12823
3/4
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
85 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12824 17 dir=down;
12825
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
68 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12826 6 dir=up;
12827
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 else if(x>0 && x<240)
12828 {
12829 62 action=none; FFCore.setHeroAction(none);
12830 62 x = x.getInt();
12831 62 y = y.getInt();
12832 62 }
12833 }
12834 191 }
12835 1276 }
12836
12837 skip:
12838
12839
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3610 times.
✓ Branch 2 taken 3451 times.
✓ Branch 3 taken 4768 times.
✓ Branch 4 taken 5341 times.
17170 switch(dir)
12840 {
12841 case up:
12842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3610 times.
3610 if(x.getInt()&15)
12843 {
12844 if(x.getInt()&8)
12845 x++;
12846 else x--;
12847 }
12848 3610 else y -= step_inc;
12849
12850 3610 break;
12851
12852 case down:
12853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3451 times.
3451 if(x.getInt()&15)
12854 {
12855 if(x.getInt()&8)
12856 x++;
12857 else x--;
12858 }
12859 3451 else y += step_inc;
12860
12861 3451 break;
12862
12863 case left:
12864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4768 times.
4768 if(y.getInt()&15)
12865 {
12866 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12867 {
12868 if ((y.getInt() % 16) < 4) y--;
12869 else y++;
12870 }
12871 else
12872 {
12873 if(y.getInt()&8)
12874 y++;
12875 else y--;
12876 }
12877 }
12878 4768 else x -= step_inc;
12879
12880 4768 break;
12881
12882 case right:
12883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5341 times.
5341 if(y.getInt()&15)
12884 {
12885 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12886 {
12887 if ((y.getInt() % 16) <= 4) y--;
12888 else y++;
12889 }
12890 else
12891 {
12892 if(y.getInt()&8)
12893 y++;
12894 else y--;
12895 }
12896 }
12897 5341 else x += step_inc;
12898
12899 5341 break;
12900 }
12901 17170 }
12902
12903 7 bool HeroClass::try_hover()
12904 {
12905
2/10
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
12906 {
12907 int32_t itemid = current_item_id(itype_hoverboots);
12908 if(hoverclk < 0)
12909 hoverclk = -hoverclk;
12910 else
12911 {
12912 fall = fakefall = jumping = 0;
12913 if(itemsbuf[itemid].misc1)
12914 hoverclk = itemsbuf[itemid].misc1;
12915 else
12916 {
12917 hoverclk = 1;
12918 hoverflags |= HOV_INF;
12919 }
12920
12921
12922 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
12923 }
12924 if(itemsbuf[itemid].wpn)
12925 decorations.add(new dHover(x, y, dHOVER, 0));
12926 return true;
12927 }
12928 7 return false;
12929 7 }
12930
12931 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
12932 //Returns '-1' if not being pulled
12933 //Returns '-2' if should be falling in
12934 13428030 int32_t HeroClass::check_pitslide(bool ignore_hover)
12935 {
12936 //Pitfall todo -Emily
12937 //Iron boots; can't fight slipping, 2px/frame
12938 //Scripted variables to read pull dir/clk (clk only for non-hero)
12939 //Implement falling for all sprite types (npc AI)
12940 // Fall/slipping tiles for enemies
12941 // Fall/slipping SFX for enemies
12942 // Fall SFX for items/weapons
12943 // Weapons/Misc sprite shared for falling items/weapons
12944 //Maybe slip SFX for Hero?
12945 // Weapons/Misc sprite override for falling sprite?
12946 //Update std.zh with relevant new stuff
12947
2/2
✓ Branch 0 taken 710149 times.
✓ Branch 1 taken 12717881 times.
13428030 if(can_pitfall(ignore_hover))
12948 {
12949
2/2
✓ Branch 0 taken 972733 times.
✓ Branch 1 taken 11745148 times.
12717881 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
12950 12717881 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
12951 12717881 int32_t ispitbl = getpitfall(x,y+15);
12952 12717881 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
12953 12717881 int32_t ispitbr = getpitfall(x+15,y+15);
12954 12717881 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
12955 12717881 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
12956 12717881 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
12957 12717881 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
12958 12717881 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
12959 12717881 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
12960 12717881 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
12961 12717881 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
12962 static const int32_t flag_pit_irresistable = (1<<24);
12963
5/5
✓ Branch 0 taken 12711658 times.
✓ Branch 1 taken 673 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 2810 times.
✓ Branch 4 taken 2666 times.
12717881 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
12964 {
12965 673 case 4: return -2; //Fully over pit; fall in
12966 case 3:
12967 {
12968
2/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
74 if(ispitul && ispitur && ispitbl) //UL_3
12969 {
12970 if(ispitul_50)
12971 {
12972 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
12973 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
12974 }
12975 }
12976
2/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
74 else if(ispitul && ispitur && ispitbr) //UR_3
12977 {
12978 if(ispitur_50)
12979 {
12980 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
12981 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
12982 }
12983 }
12984
3/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
74 else if(ispitul && ispitbl && ispitbr) //BL_3
12985 {
12986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(ispitbl_50)
12987 {
12988 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
12989 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
12990 }
12991 74 }
12992 else if(ispitbl && ispitur && ispitbr) //BR_3
12993 {
12994 if(ispitbr_50)
12995 {
12996 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
12997 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
12998 }
12999 }
13000 74 break;
13001 }
13002 case 2:
13003 {
13004
4/4
✓ Branch 0 taken 1212 times.
✓ Branch 1 taken 1598 times.
✓ Branch 2 taken 1208 times.
✓ Branch 3 taken 4 times.
2810 if(ispitul && ispitur) //Up
13005 {
13006
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(DrunkDown())
13007 {
13008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(ispitul_75 && ispitur_75) //Straight up
13009 {
13010 return up | flag_pit_irresistable | (ispitul << 8);
13011 }
13012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 else if(ispitul_75)
13013 {
13014 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13015 }
13016
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 else if(ispitur_75)
13017 {
13018 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13019 }
13020 4 else return -1;
13021 }
13022 else
13023 {
13024 if(ispitul_50 && ispitur_50) //Straight up
13025 {
13026 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13027 }
13028 else if(ispitul_50)
13029 {
13030 if(DrunkRight() && !ispitul_75) return -1;
13031 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13032 }
13033 else if(ispitur_50)
13034 {
13035 if(DrunkLeft() && !ispitur_75) return -1;
13036 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13037 }
13038 }
13039 }
13040
4/4
✓ Branch 0 taken 1510 times.
✓ Branch 1 taken 1296 times.
✓ Branch 2 taken 1208 times.
✓ Branch 3 taken 302 times.
2806 else if(ispitbl && ispitbr) //Down
13041 {
13042
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 290 times.
302 if(DrunkUp())
13043 {
13044
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(ispitbl_75 && ispitbr_75) //Straight down
13045 {
13046 return down | flag_pit_irresistable | (ispitbl << 8);
13047 }
13048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbl_75)
13049 {
13050 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13051 }
13052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbr_75)
13053 {
13054 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13055 }
13056 12 else return -1;
13057 }
13058 else
13059 {
13060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
290 if(ispitbl_50 && ispitbr_50) //Straight down
13061 {
13062 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13063 }
13064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbl_50)
13065 {
13066 if(DrunkRight() && !ispitbl_75) return -1;
13067 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13068 }
13069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbr_50)
13070 {
13071 if(DrunkLeft() && !ispitbr_75) return -1;
13072 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13073 }
13074 }
13075 290 }
13076
3/4
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 1296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1208 times.
2504 else if(ispitbl && ispitul) //Left
13077 {
13078
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1125 times.
1208 if(DrunkRight())
13079 {
13080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83 if(ispitul_75 && ispitbl_75) //Straight left
13081 {
13082 return left | flag_pit_irresistable | (ispitul << 8);
13083 }
13084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 else if(ispitul_75)
13085 {
13086 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13087 }
13088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 else if(ispitbl_75)
13089 {
13090 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13091 }
13092 83 else return -1;
13093 }
13094 else
13095 {
13096
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
1125 if(ispitul_50 && ispitbl_50) //Straight left
13097 {
13098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13099 }
13100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 else if(ispitul_50)
13101 {
13102 if(DrunkDown() && !ispitul_75) return -1;
13103 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13104 }
13105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 else if(ispitbl_50)
13106 {
13107 if(DrunkUp() && !ispitbl_75) return -1;
13108 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13109 }
13110 }
13111 1104 }
13112
2/4
✓ Branch 0 taken 1296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1296 times.
1296 else if(ispitbr && ispitur) //Right
13113 {
13114
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 1184 times.
1296 if(DrunkLeft())
13115 {
13116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 if(ispitur_75 && ispitbr_75) //Straight right
13117 {
13118 return right | flag_pit_irresistable | (ispitur << 8);
13119 }
13120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 else if(ispitur_75)
13121 {
13122 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13123 }
13124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 else if(ispitbr_75)
13125 {
13126 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13127 }
13128 112 else return -1;
13129 }
13130 else
13131 {
13132
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1168 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
1184 if(ispitur_50 && ispitbr_50) //Straight right
13133 {
13134
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13135 }
13136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1168 times.
1168 else if(ispitur_50)
13137 {
13138 if(DrunkDown() && !ispitur_75) return -1;
13139 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13140 }
13141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1168 times.
1168 else if(ispitbr_50)
13142 {
13143 if(DrunkUp() && !ispitbr_75) return -1;
13144 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13145 }
13146 }
13147 1168 }
13148 2562 break;
13149 }
13150 case 1:
13151 {
13152
3/4
✓ Branch 0 taken 940 times.
✓ Branch 1 taken 1726 times.
✓ Branch 2 taken 940 times.
✗ Branch 3 not taken.
2666 if(ispitul && ispitul_50) //UL_1
13153 {
13154 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13155 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13156 }
13157
3/4
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 2246 times.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
2666 if(ispitur && ispitur_50) //UR_1
13158 {
13159 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13160 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13161 }
13162
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 2490 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
2666 if(ispitbl && ispitbl_50) //BL_1
13163 {
13164 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13165 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13166 }
13167
3/4
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 1130 times.
✗ Branch 3 not taken.
2666 if(ispitbr && ispitbr_50) //BR_1
13168 {
13169 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13170 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13171 }
13172 2666 break;
13173 }
13174 }
13175 12716960 }
13176 13427109 return -1;
13177 13428030 }
13178
13179 2966704 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13180 {
13181 2966704 pitfall();
13182
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2966702 times.
2966704 if(fallclk) return true;
13183 2966702 int32_t val = check_pitslide();
13184 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13185
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2966698 times.
2966702 if(val == -1)
13186 {
13187 2966698 pit_pulldir = -1;
13188 2966698 pit_pullclk = 0;
13189 2966698 return false;
13190 }
13191 4 int32_t dir = val&0xFF;
13192 4 int32_t cmbid = (val&0xFFFF00)>>8;
13193 4 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13195 {
13196 pit_pulldir = -1;
13197 pit_pullclk = 0;
13198 return false;
13199 }
13200
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13201 {
13202 pit_pulldir = -1;
13203 pit_pullclk = 0;
13204 return false;
13205 }
13206 4 pit_pulldir = dir;
13207 4 int32_t step = 1;
13208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(sensitivity == 0)
13209 {
13210 4 step = 2;
13211 4 sensitivity = 1;
13212 4 }
13213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(pit_pullclk++ % sensitivity) //No pull this frame
13214 return (val&0x100);
13215
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
11 for(; step > 0 && !fallclk; --step)
13216 {
13217
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 switch(dir)
13218 {
13219 case l_up: case l_down: case left:
13220 --x; break;
13221 case r_up: case r_down: case right:
13222 7 ++x; break;
13223 }
13224
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 switch(dir)
13225 {
13226 case l_up: case r_up: case up:
13227 --y; break;
13228 case l_down: case r_down: case down:
13229 ++y; break;
13230 }
13231 7 pitfall();
13232 7 }
13233
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 return fallclk || (val&0x100);
13234 2966704 }
13235
13236 2966921 void HeroClass::pitfall()
13237 {
13238
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 2966711 times.
2966921 if(fallclk)
13239 {
13240 210 drop_liftwpn();
13241
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
210 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13242 //Handle falling
13243
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 3 times.
210 if(!--fallclk)
13244 {
13245 3 int32_t dmg = game->get_hp_per_heart()/4;
13246 3 bool dmg_perc = false;
13247 3 bool warp = false;
13248
13249 3 action=none; FFCore.setHeroAction(none);
13250
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb)
13252 {
13253 3 dmg = cmb->attributes[0]/10000L;
13254 3 dmg_perc = cmb->usrflags&cflag3;
13255 3 warp = cmb->usrflags&cflag1;
13256 3 }
13257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg) //Damage
13258 {
13259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13261 3 }
13262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(warp) //Warp
13263 {
13264 sdir = dir;
13265 if(cmb->usrflags&cflag2) //Direct Warp
13266 {
13267 didpit=true;
13268 pitx=x;
13269 pity=y;
13270 }
13271 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13272 }
13273 else //Reset to screen entry
13274 {
13275 3 go_respawn_point();
13276 }
13277 3 }
13278 210 }
13279
2/2
✓ Branch 0 taken 290222 times.
✓ Branch 1 taken 2676489 times.
2966711 else if(can_pitfall())
13280 {
13281 2676489 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13282 2676489 bool ispitbl = ispitfall(x,y+15);
13283 2676489 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13284 2676489 bool ispitbr = ispitfall(x+15,y+15);
13285 2676489 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13286
8/10
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 2676028 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 217 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 241 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
2676489 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13287 {
13288
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13289
3/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
3 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13290 3 fallclk = PITFALL_FALL_FRAMES;
13291 3 fallCombo = pitctr;
13292 3 action=falling; FFCore.setHeroAction(falling);
13293 3 spins = 0;
13294 3 charging = 0;
13295 3 drop_liftwpn();
13296 3 }
13297 2676489 }
13298 2966921 }
13299
13300 3503003 void HeroClass::movehero()
13301 {
13302
2/4
✓ Branch 0 taken 3503003 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3503003 times.
3503003 if(lstunclock || is_conveyor_stunned) return;
13303 3503003 int32_t xoff=x.getInt()&7;
13304 3503003 int32_t yoff=y.getInt()&7;
13305
2/2
✓ Branch 0 taken 3488378 times.
✓ Branch 1 taken 14625 times.
3503003 if(NO_GRIDLOCK)
13306 {
13307 14625 xoff = 0;
13308 14625 yoff = 0;
13309 14625 }
13310 3503003 int32_t push=pushing;
13311 3503003 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13312 3503003 pushing=0;
13313 3503003 zfix temp_step(hero_newstep);
13314 3503003 zfix temp_x(x);
13315 3503003 zfix temp_y(y);
13316
13317 3503003 int32_t flippers_id = current_item_id(itype_flippers);
13318
2/2
✓ Branch 0 taken 2690 times.
✓ Branch 1 taken 3500313 times.
3503003 if(diveclk>0)
13319 {
13320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2690 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2690 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13321 2690 --diveclk;
13322
4/8
✓ Branch 0 taken 1796 times.
✓ Branch 1 taken 894 times.
✓ Branch 2 taken 1796 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1796 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2690 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
13323 {
13324 diveclk = itemsbuf[flippers_id].misc2;
13325 }
13326 2690 }
13327
4/4
✓ Branch 0 taken 18339 times.
✓ Branch 1 taken 3481974 times.
✓ Branch 2 taken 18294 times.
✓ Branch 3 taken 45 times.
3500313 else if(action == swimming && DrunkrAbtn())
13328 {
13329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13330 45 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13331
13332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(global_diving==screen_diving)
13333
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13334 45 }
13335
13336
2/2
✓ Branch 0 taken 3485833 times.
✓ Branch 1 taken 17170 times.
3503003 if(action==rafting)
13337 {
13338 17170 do_rafting();
13339
13340
2/2
✓ Branch 0 taken 17036 times.
✓ Branch 1 taken 134 times.
17170 if(action==rafting)
13341 {
13342 17036 return;
13343 }
13344
13345
13346 134 set_respawn_point();
13347 134 trySideviewLadder();
13348 134 }
13349
13350 3485967 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13351 3485967 int32_t btnwpn = -1;
13352
13353 //&0xFFF removes the "bow & arrows" bitmask
13354 //The Quick Sword is allowed to interrupt attacks.
13355
4/4
✓ Branch 0 taken 3405218 times.
✓ Branch 1 taken 80749 times.
✓ Branch 2 taken 2372338 times.
✓ Branch 3 taken 1032880 times.
3485967 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13356
8/8
✓ Branch 0 taken 2962052 times.
✓ Branch 1 taken 523915 times.
✓ Branch 2 taken 2958767 times.
✓ Branch 3 taken 3285 times.
✓ Branch 4 taken 124287 times.
✓ Branch 5 taken 402913 times.
✓ Branch 6 taken 33262 times.
✓ Branch 7 taken 493938 times.
3485967 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13357 {
13358
2/2
✓ Branch 0 taken 9299 times.
✓ Branch 1 taken 2982730 times.
2992029 if(DrunkrBbtn())
13359 {
13360 9299 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13361 9299 dowpn = Bwpn&0xFFF;
13362 9299 directWpn = directItemB;
13363 9299 }
13364
2/2
✓ Branch 0 taken 30065 times.
✓ Branch 1 taken 2952665 times.
2982730 else if(DrunkrAbtn())
13365 {
13366 30065 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13367 30065 dowpn = Awpn&0xFFF;
13368 30065 directWpn = directItemA;
13369 30065 }
13370
4/4
✓ Branch 0 taken 71669 times.
✓ Branch 1 taken 2880996 times.
✓ Branch 2 taken 71662 times.
✓ Branch 3 taken 7 times.
2952665 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13371 {
13372 7 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13373 7 dowpn = Xwpn&0xFFF;
13374 7 directWpn = directItemX;
13375 7 }
13376
4/4
✓ Branch 0 taken 71662 times.
✓ Branch 1 taken 2880996 times.
✓ Branch 2 taken 71557 times.
✓ Branch 3 taken 105 times.
2952658 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13377 {
13378 105 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13379 105 dowpn = Ywpn&0xFFF;
13380 105 directWpn = directItemY;
13381 105 }
13382
13383
1/2
✓ Branch 0 taken 2992029 times.
✗ Branch 1 not taken.
2992029 if(directWpn > 255) directWpn = 0;
13384
13385 // The Quick Sword only allows repeated sword or wand swings.
13386
7/8
✓ Branch 0 taken 2958767 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 33262 times.
✓ Branch 3 taken 2958767 times.
✓ Branch 4 taken 32749 times.
✓ Branch 5 taken 513 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2959280 times.
2992029 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13387 32749 btnwpn=-1;
13388 2992029 }
13389
13390
2/2
✓ Branch 0 taken 3168263 times.
✓ Branch 1 taken 317704 times.
3485967 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13391
11/12
✓ Branch 0 taken 3361853 times.
✓ Branch 1 taken 124114 times.
✓ Branch 2 taken 3324995 times.
✓ Branch 3 taken 36858 times.
✓ Branch 4 taken 3250379 times.
✓ Branch 5 taken 74616 times.
✓ Branch 6 taken 3219814 times.
✓ Branch 7 taken 30565 times.
✓ Branch 8 taken 29769 times.
✓ Branch 9 taken 3190045 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 29769 times.
3485967 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13392 {
13393
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 28203 times.
29769 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13394
4/6
✓ Branch 0 taken 29769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 29754 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
29769 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13395 {
13396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29754 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29754 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13397 {
13398 paymagiccost(attackid,true);
13399 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13400 }
13401 29754 SetAttack();
13402 29754 attack=wSword;
13403
13404 29754 attackclk=0;
13405
2/2
✓ Branch 0 taken 1551 times.
✓ Branch 1 taken 28203 times.
29754 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13406
13407
2/10
✓ Branch 0 taken 29754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29754 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
29754 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13408 {
13409 if(!checkmagiccost(dowpn))
13410 {
13411 item_error();
13412 }
13413 else
13414 {
13415 //clear the item script stack for a new script
13416
13417 ri = &(itemScriptData[dowpn]);
13418 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13419 ri->Clear();
13420 //itemScriptData[(dowpn & 0xFFF)].Clear();
13421 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13422 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13423 item_doscript[dowpn] = 1;
13424 itemscriptInitialised[dowpn] = 0;
13425 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13426 did_scripta=true;
13427 }
13428 }
13429 29754 }
13430 else
13431 {
13432 15 item_error();
13433 }
13434 29769 }
13435 else
13436 {
13437 3456198 did_scripta=false;
13438 }
13439
13440
7/10
✓ Branch 0 taken 3464938 times.
✓ Branch 1 taken 21029 times.
✓ Branch 2 taken 3464938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3464938 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3464938 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 214 times.
✓ Branch 9 taken 3464724 times.
3485967 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13441 {
13442
4/4
✓ Branch 0 taken 560633 times.
✓ Branch 1 taken 2904091 times.
✓ Branch 2 taken 560628 times.
✓ Branch 3 taken 5 times.
3464724 if(DrunkUp() && canSideviewLadder())
13443 {
13444 5 setOnSideviewLadder(true);
13445 5 }
13446
3/4
✓ Branch 0 taken 454622 times.
✓ Branch 1 taken 3010097 times.
✓ Branch 2 taken 454622 times.
✗ Branch 3 not taken.
3464719 else if(DrunkDown() && canSideviewLadder(true))
13447 {
13448 y+=1;
13449 setOnSideviewLadder(true);
13450 }
13451 3464724 }
13452
13453 3485967 int32_t wx=x;
13454 3485967 int32_t wy=y;
13455
5/6
✓ Branch 0 taken 2412132 times.
✓ Branch 1 taken 1073835 times.
✓ Branch 2 taken 219 times.
✓ Branch 3 taken 3485748 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 219 times.
3485967 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13456 {
13457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((xoff==0)||diagonalMovement)
13458 {
13459
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 180 times.
219 if(DrunkUp()) dir=up;
13460
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if(DrunkDown()) dir=down;
13461 219 }
13462
13463
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((yoff==0)||diagonalMovement)
13464 {
13465
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 23 times.
219 if(DrunkLeft()) dir=left;
13466
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 29 times.
219 if(DrunkRight()) dir=right;
13467 219 }
13468 219 }
13469
13470
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 798903 times.
✓ Branch 2 taken 662726 times.
✓ Branch 3 taken 974274 times.
✓ Branch 4 taken 1050064 times.
3485967 switch(dir)
13471 {
13472 case up:
13473 798903 wy-=16;
13474 798903 break;
13475
13476 case down:
13477 662726 wy+=16;
13478 662726 break;
13479
13480 case left:
13481 974274 wx-=16;
13482 974274 break;
13483
13484 case right:
13485 1050064 wx+=16;
13486 1050064 break;
13487 }
13488
13489 3485967 do_lens();
13490
13491 3485967 WalkflagInfo info;
13492
13493 3485967 bool no_jinx = true;
13494
7/8
✓ Branch 0 taken 3361853 times.
✓ Branch 1 taken 124114 times.
✓ Branch 2 taken 9312 times.
✓ Branch 3 taken 3352541 times.
✓ Branch 4 taken 9312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 9288 times.
3485967 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13495 {
13496 9288 bool paidmagic = false;
13497
6/8
✓ Branch 0 taken 8089 times.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 489 times.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 489 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1199 times.
9288 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13498 {
13499
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 710 times.
1199 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13500 1199 no_jinx = checkitem_jinx(attackid);
13501
3/8
✓ Branch 0 taken 1199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1199 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1199 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1199 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13502 {
13503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1199 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13504 paymagiccost(attackid,true);
13505 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13506 }
13507 1199 SetAttack();
13508 1199 attack=wWand;
13509 1199 attackclk=0;
13510 1199 }
13511 else
13512 {
13513 item_error();
13514 }
13515 1199 }
13516
4/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 8002 times.
✓ Branch 2 taken 87 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 87 times.
8176 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13517
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
87 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13518 {
13519 87 no_jinx = checkitem_jinx(dowpn);
13520
3/6
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 87 times.
87 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13521 {
13522 item_error();
13523 }
13524 else
13525 {
13526 87 paymagiccost(dowpn);
13527 87 paidmagic = true;
13528 87 SetAttack();
13529 87 attack=wHammer;
13530
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 2 times.
87 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13531 87 attackclk=0;
13532 }
13533 87 }
13534
4/6
✓ Branch 0 taken 982 times.
✓ Branch 1 taken 7020 times.
✓ Branch 2 taken 982 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 982 times.
8984 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13535
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 982 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
982 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13536 {
13537 //checkbunny handled where magic cost is paid
13538
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 168 times.
982 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13539 982 no_jinx = checkitem_jinx(attackid);
13540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 982 times.
982 if(no_jinx)
13541 {
13542 982 SetAttack();
13543 982 attack=wFire;
13544 982 attackclk=0;
13545 982 }
13546 982 }
13547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7020 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7020 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13548 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13549 {
13550 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13551 no_jinx = checkitem_jinx(attackid);
13552 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13553 {
13554 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13555 paymagiccost(attackid,true);
13556 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13557 }
13558 SetAttack();
13559 attack=wCByrna;
13560 attackclk=0;
13561 }
13562 else
13563 {
13564 item_error();
13565 }
13566 }
13567
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7020 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7020 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13568 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13569 {
13570 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13571 no_jinx = checkitem_jinx(attackid);
13572 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13573 {
13574 paymagiccost(attackid);
13575 SetAttack();
13576 attack = wBugNet;
13577 attackclk = 0;
13578 sfx(itemsbuf[attackid].usesound);
13579 }
13580 else
13581 {
13582 item_error();
13583 }
13584 }
13585 else
13586 {
13587
2/2
✓ Branch 0 taken 6943 times.
✓ Branch 1 taken 77 times.
7020 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13588 7020 no_jinx = checkitem_jinx(itmid);
13589
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 7006 times.
7020 if(no_jinx)
13590 {
13591 7006 paidmagic = startwpn(itmid);
13592
13593
2/2
✓ Branch 0 taken 6005 times.
✓ Branch 1 taken 1001 times.
7006 if(paidmagic)
13594 {
13595
5/10
✓ Branch 0 taken 6005 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6005 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6005 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6005 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6005 times.
6005 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13596 {
13597 ;
13598 }
13599 else
13600 {
13601 6005 SetAttack();
13602 6005 attackclk=0;
13603 6005 attack=none;
13604
13605
2/2
✓ Branch 0 taken 869 times.
✓ Branch 1 taken 5136 times.
6005 if(btnwpn==itype_brang)
13606 {
13607 5136 attack=wBrang;
13608 5136 }
13609 }
13610 6005 }
13611 else
13612 {
13613 // Weapon not started: directWpn should be reset to prev. value.
13614 1001 directWpn = olddirectwpn;
13615 }
13616 7006 }
13617 }
13618
13619
8/12
✓ Branch 0 taken 9288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9274 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 482 times.
✓ Branch 5 taken 8792 times.
✓ Branch 6 taken 416 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 416 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
9288 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13620 {
13621
3/4
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 416 times.
416 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13622 {
13623 item_error();
13624 }
13625 else
13626 {
13627 // Only charge for magic if item's magic cost wasn't already charged
13628 // for the item's main use.
13629
4/4
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 411 times.
416 if(!paidmagic && attack!=wWand)
13630 411 paymagiccost(dowpn);
13631 //clear the item script stack for a new script
13632 //itemScriptData[(dowpn & 0xFFF)].Clear();
13633 416 ri = &(itemScriptData[dowpn]);
13634
2/2
✓ Branch 0 taken 425984 times.
✓ Branch 1 taken 416 times.
426400 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13635 416 ri->Clear();
13636 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13637 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13638 416 item_doscript[dowpn] = 1;
13639 416 itemscriptInitialised[dowpn] = 0;
13640 416 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13641 416 did_scriptb=true;
13642 }
13643 416 }
13644
13645
7/12
✓ Branch 0 taken 9274 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 9274 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9274 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9274 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9274 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9274 times.
9288 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13646 {
13647 return;
13648 }
13649
2/2
✓ Branch 0 taken 9274 times.
✓ Branch 1 taken 14 times.
9288 if(!no_jinx)
13650 14 did_scriptb = false;
13651 9288 }
13652 else
13653 {
13654 3476679 did_scriptb=false;
13655 }
13656
13657
5/6
✓ Branch 0 taken 2962564 times.
✓ Branch 1 taken 523403 times.
✓ Branch 2 taken 2921251 times.
✓ Branch 3 taken 41313 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2921251 times.
3485967 if(attackclk || action==attacking || action==sideswimattacking)
13658 {
13659
13660
4/8
✓ Branch 0 taken 41313 times.
✓ Branch 1 taken 523403 times.
✓ Branch 2 taken 41313 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 41313 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
564716 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13661 {
13662 if((xoff==0)||diagonalMovement)
13663 {
13664 if(DrunkUp()) dir=up;
13665 if(DrunkDown()) dir=down;
13666 }
13667
13668 if((yoff==0)||diagonalMovement)
13669 {
13670 if(DrunkLeft()) dir=left;
13671 if(DrunkRight()) dir=right;
13672 }
13673 }
13674
13675 564716 bool attacked = doattack();
13676
13677 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
13678
10/12
✓ Branch 0 taken 563117 times.
✓ Branch 1 taken 1599 times.
✓ Branch 2 taken 399863 times.
✓ Branch 3 taken 163254 times.
✓ Branch 4 taken 75860 times.
✓ Branch 5 taken 324003 times.
✓ Branch 6 taken 74184 times.
✓ Branch 7 taken 1676 times.
✓ Branch 8 taken 74184 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 74184 times.
564716 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
13679 {
13680
4/4
✓ Branch 0 taken 32986 times.
✓ Branch 1 taken 41198 times.
✓ Branch 2 taken 4695 times.
✓ Branch 3 taken 28291 times.
74184 if((xoff==0)||diagonalMovement)
13681 {
13682
2/2
✓ Branch 0 taken 41961 times.
✓ Branch 1 taken 3932 times.
45893 if(DrunkUp()) dir=up;
13683
13684
2/2
✓ Branch 0 taken 41514 times.
✓ Branch 1 taken 4379 times.
45893 if(DrunkDown()) dir=down;
13685 45893 }
13686
13687
4/4
✓ Branch 0 taken 23358 times.
✓ Branch 1 taken 50826 times.
✓ Branch 2 taken 3273 times.
✓ Branch 3 taken 20085 times.
74184 if((yoff==0)||diagonalMovement)
13688 {
13689
2/2
✓ Branch 0 taken 48464 times.
✓ Branch 1 taken 5635 times.
54099 if(DrunkLeft()) dir=left;
13690
13691
2/2
✓ Branch 0 taken 48693 times.
✓ Branch 1 taken 5406 times.
54099 if(DrunkRight()) dir=right;
13692 54099 }
13693 74184 }
13694
13695
9/10
✓ Branch 0 taken 525586 times.
✓ Branch 1 taken 39130 times.
✓ Branch 2 taken 523665 times.
✓ Branch 3 taken 1921 times.
✓ Branch 4 taken 523230 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 519015 times.
✓ Branch 7 taken 4215 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 519015 times.
564716 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
13696 {
13697 519015 return;
13698 }
13699
2/2
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 39130 times.
45701 else if(!(attacked))
13700 {
13701 // Spin attack - change direction
13702
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 38882 times.
39130 if(spins>1)
13703 {
13704 248 spins--;
13705
13706
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 45 times.
248 if(spins%5==0)
13707 45 sfx(itemsbuf[current_item_id(spins >5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
13708
13709 248 attackclk=1;
13710
13711
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
248 switch(dir)
13712 {
13713 case up:
13714 62 dir=left;
13715 62 break;
13716
13717 case right:
13718 62 dir=up;
13719 62 break;
13720
13721 case down:
13722 62 dir=right;
13723 62 break;
13724
13725 case left:
13726 62 dir=down;
13727 62 break;
13728 }
13729
13730 248 return;
13731 }
13732 else
13733 {
13734 38882 spins=0;
13735 }
13736
13737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38882 times.
38882 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
13738 38882 else {action=none; FFCore.setHeroAction(none);}
13739 38882 attackclk=0;
13740 38882 charging=0;
13741 38882 }
13742 45453 }
13743
13744
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2966701 times.
2966704 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
13745 3 return;
13746
13747
2/2
✓ Branch 0 taken 1136312 times.
✓ Branch 1 taken 1830389 times.
2966701 if(action==walking) //still walking
13748 {
13749
9/10
✓ Branch 0 taken 1380884 times.
✓ Branch 1 taken 449505 times.
✓ Branch 2 taken 1029964 times.
✓ Branch 3 taken 350920 times.
✓ Branch 4 taken 544786 times.
✓ Branch 5 taken 485178 times.
✓ Branch 6 taken 22616 times.
✓ Branch 7 taken 522170 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 22616 times.
1830389 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
13750 {
13751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22616 times.
22616 if(attackclk>0) SetAttack();
13752 22616 else {action = none; FFCore.setHeroAction(none);}
13753 22616 hero_count=-1;
13754 22616 return;
13755 }
13756
13757 1807773 autostep=false;
13758
13759
3/4
✓ Branch 0 taken 1608398 times.
✓ Branch 1 taken 199375 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1608398 times.
1807773 if(!(diagonalMovement || NO_GRIDLOCK))
13760 {
13761
2/4
✓ Branch 0 taken 1608398 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1608398 times.
1608398 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
13762 {
13763 if(dir==up&&yoff)
13764 {
13765 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
13766 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
13767 execute(info);
13768
13769 if(!info.isUnwalkable())
13770 {
13771 move(up);
13772 }
13773 else
13774 {
13775 action=none; FFCore.setHeroAction(none);
13776 }
13777
13778 return;
13779 }
13780
13781 if(dir==down&&yoff)
13782 {
13783 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
13784 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
13785 execute(info);
13786
13787 if(!info.isUnwalkable())
13788 {
13789 move(down);
13790 }
13791 else
13792 {
13793 action=none; FFCore.setHeroAction(none);
13794 }
13795
13796 return;
13797 }
13798
13799 if(dir==left&&xoff)
13800 {
13801 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
13802 execute(info);
13803
13804 if(!info.isUnwalkable())
13805 {
13806 move(left);
13807 }
13808 else
13809 {
13810 action=none; FFCore.setHeroAction(none);
13811 }
13812
13813 return;
13814 }
13815
13816 if(dir==right&&xoff)
13817 {
13818 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
13819 execute(info);
13820
13821 if(!info.isUnwalkable())
13822 {
13823 move(right);
13824 }
13825 else
13826 {
13827 action=none; FFCore.setHeroAction(none);
13828 }
13829
13830 return;
13831 }
13832 }
13833 else
13834 {
13835
4/4
✓ Branch 0 taken 382498 times.
✓ Branch 1 taken 1225900 times.
✓ Branch 2 taken 62730 times.
✓ Branch 3 taken 319768 times.
1608398 if(dir==up&&yoff)
13836 {
13837 319768 while(true)
13838 {
13839 319768 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
13840 319768 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
13841 319768 execute(info);
13842
13843
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 318757 times.
319768 if(!info.isUnwalkable())
13844 {
13845 318757 hero_newstep = temp_step;
13846 318757 x = temp_x;
13847 318757 y = temp_y;
13848 318757 move(up);
13849 318757 return;
13850 }
13851 //Could not move, try moving less
13852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1011 times.
1011 if(temp_y != int32_t(temp_y))
13853 {
13854 temp_y = floor((double)temp_y);
13855 continue;
13856 }
13857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1011 times.
1011 else if(temp_step > 1)
13858 {
13859 if(temp_step != int32_t(temp_step)) //floor
13860 temp_step = floor((double)temp_step);
13861 else --temp_step;
13862 continue;
13863 }
13864 else //Can't move less, stop moving
13865 {
13866 1011 action=none; FFCore.setHeroAction(none);
13867 }
13868 1011 return;
13869 }
13870 }
13871
13872
4/4
✓ Branch 0 taken 300651 times.
✓ Branch 1 taken 987979 times.
✓ Branch 2 taken 49648 times.
✓ Branch 3 taken 251003 times.
1288630 if(dir==down&&yoff)
13873 {
13874 251003 while(true)
13875 {
13876 251007 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
13877 251007 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
13878 251007 execute(info);
13879
13880
2/2
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 250177 times.
251007 if(!info.isUnwalkable())
13881 {
13882 250177 hero_newstep = temp_step;
13883 250177 x = temp_x;
13884 250177 y = temp_y;
13885 250177 move(down);
13886 250177 return;
13887 }
13888 //Could not move, try moving less
13889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 830 times.
830 if(temp_y != int32_t(temp_y))
13890 {
13891 temp_y = floor((double)temp_y);
13892 continue;
13893 }
13894
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 826 times.
830 else if(temp_step > 1)
13895 {
13896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(temp_step != int32_t(temp_step)) //floor
13897 4 temp_step = floor((double)temp_step);
13898 else --temp_step;
13899 4 continue;
13900 }
13901 else //Can't move less, stop moving
13902 {
13903 826 action=none; FFCore.setHeroAction(none);
13904 }
13905 826 return;
13906 }
13907 }
13908
13909
4/4
✓ Branch 0 taken 447026 times.
✓ Branch 1 taken 590601 times.
✓ Branch 2 taken 74975 times.
✓ Branch 3 taken 372051 times.
1037627 if(dir==left&&xoff)
13910 {
13911 372051 while(true)
13912 {
13913 372051 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
13914 372051 execute(info);
13915
13916
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 371282 times.
372051 if(!info.isUnwalkable())
13917 {
13918 371282 hero_newstep = temp_step;
13919 371282 x = temp_x;
13920 371282 y = temp_y;
13921 371282 move(left);
13922 371282 return;
13923 }
13924 //Could not move, try moving less
13925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 769 times.
769 if(temp_x != int32_t(temp_x))
13926 {
13927 temp_x = floor((double)temp_x);
13928 continue;
13929 }
13930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 769 times.
769 else if(temp_step > 1)
13931 {
13932 if(temp_step != int32_t(temp_step)) //floor
13933 temp_step = floor((double)temp_step);
13934 else --temp_step;
13935 continue;
13936 }
13937 else //Can't move less, stop moving
13938 {
13939 769 action=none; FFCore.setHeroAction(none);
13940 }
13941 769 return;
13942 }
13943 }
13944
13945
4/4
✓ Branch 0 taken 478223 times.
✓ Branch 1 taken 187353 times.
✓ Branch 2 taken 79960 times.
✓ Branch 3 taken 398263 times.
665576 if(dir==right&&xoff)
13946 {
13947 398263 while(true)
13948 {
13949 398269 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
13950 398269 execute(info);
13951
13952
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 397390 times.
398269 if(!info.isUnwalkable())
13953 {
13954 397390 hero_newstep = temp_step;
13955 397390 x = temp_x;
13956 397390 y = temp_y;
13957 397390 move(right);
13958 397390 return;
13959 }
13960 //Could not move, try moving less
13961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 879 times.
879 if(temp_x != int32_t(temp_x))
13962 {
13963 temp_x = floor((double)temp_x);
13964 continue;
13965 }
13966
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 873 times.
879 else if(temp_step > 1)
13967 {
13968
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
13969 6 temp_step = floor((double)temp_step);
13970 else --temp_step;
13971 6 continue;
13972 }
13973 else //Can't move less, stop moving
13974 {
13975 873 action=none; FFCore.setHeroAction(none);
13976 }
13977 873 return;
13978 }
13979 }
13980 }
13981 267313 }
13982
13983 466688 } // endif (action==walking)
13984
13985
16/24
✓ Branch 0 taken 1581971 times.
✓ Branch 1 taken 21029 times.
✓ Branch 2 taken 1581971 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1581971 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1581971 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1581971 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1581971 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1581971 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1581971 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1581971 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1580050 times.
✓ Branch 19 taken 1921 times.
✓ Branch 20 taken 1579615 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 76031 times.
✓ Branch 23 taken 1503584 times.
1603000 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
13986 {
13987 1503584 action=none; FFCore.setHeroAction(none);
13988 1503584 }
13989
13990
2/2
✓ Branch 0 taken 451736 times.
✓ Branch 1 taken 1151264 times.
1603000 if(diagonalMovement)
13991 {
13992
5/5
✓ Branch 0 taken 155626 times.
✓ Branch 1 taken 48000 times.
✓ Branch 2 taken 36867 times.
✓ Branch 3 taken 99030 times.
✓ Branch 4 taken 112213 times.
451736 switch(holddir)
13993 {
13994 case up:
13995
2/2
✓ Branch 0 taken 46435 times.
✓ Branch 1 taken 1565 times.
48000 if(!Up())
13996 {
13997 1565 holddir=-1;
13998 1565 }
13999
14000 48000 break;
14001
14002 case down:
14003
2/2
✓ Branch 0 taken 35423 times.
✓ Branch 1 taken 1444 times.
36867 if(!Down())
14004 {
14005 1444 holddir=-1;
14006 1444 }
14007
14008 36867 break;
14009
14010 case left:
14011
2/2
✓ Branch 0 taken 95832 times.
✓ Branch 1 taken 3198 times.
99030 if(!Left())
14012 {
14013 3198 holddir=-1;
14014 3198 }
14015
14016 99030 break;
14017
14018 case right:
14019
2/2
✓ Branch 0 taken 108810 times.
✓ Branch 1 taken 3403 times.
112213 if(!Right())
14020 {
14021 3403 holddir=-1;
14022 3403 }
14023
14024 112213 break;
14025
14026 default:
14027 155626 break;
14028 } //end switch
14029
14030
3/4
✓ Branch 0 taken 322844 times.
✓ Branch 1 taken 128892 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 322844 times.
451736 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14031 {
14032 128892 walkable = false;
14033
6/6
✓ Branch 0 taken 22753 times.
✓ Branch 1 taken 106139 times.
✓ Branch 2 taken 22076 times.
✓ Branch 3 taken 677 times.
✓ Branch 4 taken 6363 times.
✓ Branch 5 taken 15713 times.
128892 if(DrunkUp()&&(holddir==-1||holddir==up))
14034 {
14035
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16390 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14036 {
14037 }
14038 else
14039 {
14040
4/10
✓ Branch 0 taken 16390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16390 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16390 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16390 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14041 {
14042 16390 dir=up;
14043 16390 }
14044
14045 16390 holddir=up;
14046
14047
4/4
✓ Branch 0 taken 2060 times.
✓ Branch 1 taken 14330 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 2055 times.
16390 if(DrunkRight()&&shiftdir!=left)
14048 {
14049 2055 shiftdir=right;
14050
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2055 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14051
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2055 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14052 2055 }
14053
4/4
✓ Branch 0 taken 2050 times.
✓ Branch 1 taken 12285 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2048 times.
14335 else if(DrunkLeft()&&shiftdir!=right)
14054 {
14055 2048 shiftdir=left;
14056
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2048 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14057
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2048 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14058 2048 }
14059 else
14060 {
14061 12287 shiftdir=-1;
14062 }
14063
14064 //walkable if Ladder can be placed or is already placed vertically
14065
9/20
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 16196 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 55 times.
✓ Branch 13 taken 139 times.
✓ Branch 14 taken 55 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 55 times.
16390 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14066 {
14067 55 walkable=false;
14068 55 }
14069 else
14070 {
14071 16335 do
14072 {
14073 18969 info = walkflag(x,(bigHitbox?0:8)+(y-hero_newstep),2,up);
14074
14075 18969 info = info || walkflag(x+15,(bigHitbox?0:8)+(y-hero_newstep),1,up);
14076 18969 info = info || walkflagMBlock(x+15, (bigHitbox?0:8)+(y-hero_newstep));
14077
14078 18969 execute(info);
14079
14080
2/2
✓ Branch 0 taken 5093 times.
✓ Branch 1 taken 13876 times.
18969 if(info.isUnwalkable())
14081 {
14082
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 4918 times.
5093 if(y != y.getInt())
14083 {
14084 175 y.doRound();
14085 175 }
14086
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 2459 times.
4918 else if(hero_newstep > 1)
14087 {
14088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2459 times.
2459 if(hero_newstep != int32_t(hero_newstep)) //floor
14089 2459 hero_newstep = floor((double)hero_newstep);
14090 else --hero_newstep;
14091 2459 }
14092 else
14093 2459 break;
14094 2634 }
14095 13876 else walkable = true;
14096
2/2
✓ Branch 0 taken 2634 times.
✓ Branch 1 taken 13876 times.
16510 }
14097 16510 while(!walkable);
14098 }
14099
14100 16390 int32_t s=shiftdir;
14101
14102
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16390 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14103 {
14104 shiftdir=-1;
14105 }
14106 else
14107 {
14108
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 14342 times.
16390 if(s==left)
14109 {
14110 2048 do
14111 {
14112 2452 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14113
14114 2452 execute(info);
14115
14116
2/2
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 1677 times.
2452 if(info.isUnwalkable())
14117 {
14118
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 742 times.
775 if(x != x.getInt())
14119 {
14120 33 x.doRound();
14121 33 }
14122
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 371 times.
742 else if(hero_newstep_diag > 1)
14123 {
14124
1/2
✓ Branch 0 taken 371 times.
✗ Branch 1 not taken.
371 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14125 371 hero_newstep_diag.doFloor();
14126 else --hero_newstep_diag;
14127 371 }
14128 else
14129 371 shiftdir = -1;
14130 775 }
14131
2/2
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 259 times.
1677 else if(walkable)
14132 {
14133 1418 do
14134 {
14135 1422 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14136 1422 execute(info);
14137
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1415 times.
1422 if(info.isUnwalkable())
14138 {
14139
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
7 if(x != x.getInt())
14140 {
14141 1 x.doRound();
14142 1 }
14143
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14144 {
14145
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14146 3 hero_newstep_diag.doFloor();
14147 else --hero_newstep_diag;
14148 3 }
14149 else
14150 3 shiftdir = -1;
14151 7 }
14152 1415 else break;
14153
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 }
14154 7 while(shiftdir != -1);
14155 1418 break;
14156 }
14157 259 else break;
14158
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 371 times.
775 }
14159 775 while(shiftdir != -1);
14160 2048 }
14161
2/2
✓ Branch 0 taken 12287 times.
✓ Branch 1 taken 2055 times.
14342 else if(s==right)
14162 {
14163 2055 do
14164 {
14165 2373 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14166
14167 2373 execute(info);
14168
14169
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 1772 times.
2373 if(info.isUnwalkable())
14170 {
14171
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 566 times.
601 if(x != x.getInt())
14172 {
14173 35 x.doRound();
14174 35 }
14175
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 283 times.
566 else if(hero_newstep_diag > 1)
14176 {
14177
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14178 283 hero_newstep_diag.doFloor();
14179 else --hero_newstep_diag;
14180 283 }
14181 else
14182 283 shiftdir = -1;
14183 601 }
14184
2/2
✓ Branch 0 taken 1442 times.
✓ Branch 1 taken 330 times.
1772 else if(walkable)
14185 {
14186 1442 do
14187 {
14188 1448 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14189 1448 execute(info);
14190
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1437 times.
1448 if(info.isUnwalkable())
14191 {
14192
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14193 {
14194 1 x.doRound();
14195 1 }
14196
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14197 {
14198
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14199 5 hero_newstep_diag.doFloor();
14200 else --hero_newstep_diag;
14201 5 }
14202 else
14203 5 shiftdir = -1;
14204 11 }
14205 1437 else break;
14206
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14207 11 while(shiftdir != -1);
14208 1442 break;
14209 }
14210 330 else break;
14211
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 283 times.
601 }
14212 601 while(shiftdir != -1);
14213 2055 }
14214 }
14215
14216 16390 move(up);
14217 16390 shiftdir=s;
14218
14219
2/2
✓ Branch 0 taken 13876 times.
✓ Branch 1 taken 2514 times.
16390 if(!walkable)
14220 {
14221
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 1854 times.
2514 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14222 {
14223 1854 x = x.getInt();
14224 1854 y = y.getInt();
14225
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1854 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1854 times.
✓ Branch 4 taken 1576 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 111 times.
✓ Branch 7 taken 1743 times.
2132 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14226
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✓ Branch 4 taken 115 times.
✓ Branch 5 taken 163 times.
278 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14227
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14228 {
14229
5/8
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 111 times.
111 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14230 111 sprite::move((zfix)-1,(zfix)0);
14231 111 }
14232 else
14233 {
14234
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1743 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1743 times.
✓ Branch 4 taken 167 times.
✓ Branch 5 taken 1576 times.
✓ Branch 6 taken 129 times.
✓ Branch 7 taken 1614 times.
3319 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14235
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1447 times.
✓ Branch 5 taken 129 times.
1576 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14236
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14237 {
14238
4/8
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
129 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14239 129 sprite::move((zfix)1,(zfix)0);
14240 129 }
14241 else
14242 {
14243 1614 pushing=push+1;
14244 }
14245 }
14246 1854 }
14247 else
14248 {
14249 660 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14250 }
14251 2514 }
14252
14253 16390 return;
14254 }
14255 }
14256
14257
6/6
✓ Branch 0 taken 21937 times.
✓ Branch 1 taken 90565 times.
✓ Branch 2 taken 21177 times.
✓ Branch 3 taken 760 times.
✓ Branch 4 taken 15820 times.
✓ Branch 5 taken 5357 times.
112502 if(DrunkDown()&&(holddir==-1||holddir==down))
14258 {
14259
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16580 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14260 {
14261 }
14262 else
14263 {
14264
4/10
✓ Branch 0 taken 16580 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16580 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16580 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16580 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16580 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14265 {
14266 16580 dir=down;
14267 16580 }
14268
14269 16580 holddir=down;
14270
14271
3/4
✓ Branch 0 taken 2833 times.
✓ Branch 1 taken 13747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2833 times.
16580 if(DrunkRight()&&shiftdir!=left)
14272 {
14273 2833 shiftdir=right;
14274
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2833 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14275
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2833 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14276 2833 }
14277
4/4
✓ Branch 0 taken 2602 times.
✓ Branch 1 taken 11145 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2601 times.
13747 else if(DrunkLeft()&&shiftdir!=right)
14278 {
14279 2601 shiftdir=left;
14280
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2601 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2601 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14281
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2601 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2601 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14282 2601 }
14283 else
14284 {
14285 11146 shiftdir=-1;
14286 }
14287
14288 //bool walkable;
14289
7/12
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 15920 times.
✓ Branch 2 taken 660 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 660 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 660 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 660 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 660 times.
16580 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14290 {
14291 660 walkable=false;
14292 660 }
14293 else
14294 {
14295 15920 do
14296 {
14297 17942 info = walkflag(x,15+(y+hero_newstep),2,down);
14298
14299
2/2
✓ Branch 0 taken 10468 times.
✓ Branch 1 taken 7474 times.
17942 if(x.getFloor() & 7)
14300 10468 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14301 else
14302 7474 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14303
14304 17942 execute(info);
14305
14306
2/2
✓ Branch 0 taken 3831 times.
✓ Branch 1 taken 14111 times.
17942 if(info.isUnwalkable())
14307 {
14308
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 3621 times.
3831 if(y != y.getInt())
14309 {
14310 210 y.doRound();
14311 210 }
14312
2/2
✓ Branch 0 taken 1812 times.
✓ Branch 1 taken 1809 times.
3621 else if(hero_newstep > 1)
14313 {
14314
1/2
✓ Branch 0 taken 1812 times.
✗ Branch 1 not taken.
1812 if(hero_newstep != int32_t(hero_newstep)) //floor
14315 1812 hero_newstep = floor((double)hero_newstep);
14316 else --hero_newstep;
14317 1812 }
14318 else
14319 1809 break;
14320 2022 }
14321 14111 else walkable = true;
14322
2/2
✓ Branch 0 taken 2022 times.
✓ Branch 1 taken 14111 times.
16133 }
14323 16133 while(!walkable);
14324 }
14325
14326 16580 int32_t s=shiftdir;
14327
14328
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16580 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14329 {
14330 shiftdir=-1;
14331 }
14332 else
14333 {
14334
2/2
✓ Branch 0 taken 2601 times.
✓ Branch 1 taken 13979 times.
16580 if(s==left)
14335 {
14336 2601 do
14337 {
14338 2995 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14339
14340 2995 execute(info);
14341
14342
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 2255 times.
2995 if(info.isUnwalkable())
14343 {
14344
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 692 times.
740 if(x != x.getInt())
14345 {
14346 48 x.doRound();
14347 48 }
14348
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 346 times.
692 else if(hero_newstep_diag > 1)
14349 {
14350
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14351 346 hero_newstep_diag.doFloor();
14352 else --hero_newstep_diag;
14353 346 }
14354 else
14355 346 shiftdir = -1;
14356 740 }
14357
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 466 times.
2255 else if(walkable)
14358 {
14359 1789 do
14360 {
14361 1796 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14362 1796 execute(info);
14363
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1786 times.
1796 if(info.isUnwalkable())
14364 {
14365
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(x != x.getInt())
14366 {
14367 4 x.doRound();
14368 4 }
14369
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14370 {
14371
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14372 3 hero_newstep_diag.doFloor();
14373 else --hero_newstep_diag;
14374 3 }
14375 else
14376 3 shiftdir = -1;
14377 10 }
14378 1786 else break;
14379
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 }
14380 10 while(shiftdir != -1);
14381 1789 break;
14382 }
14383 466 else break;
14384
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 346 times.
740 }
14385 740 while(shiftdir != -1);
14386 2601 }
14387
2/2
✓ Branch 0 taken 11146 times.
✓ Branch 1 taken 2833 times.
13979 else if(s==right)
14388 {
14389 2833 do
14390 {
14391 3166 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14392
14393 3166 execute(info);
14394
14395
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 2524 times.
3166 if(info.isUnwalkable())
14396 {
14397
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 618 times.
642 if(x != x.getInt())
14398 {
14399 24 x.doRound();
14400 24 }
14401
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 309 times.
618 else if(hero_newstep_diag > 1)
14402 {
14403
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14404 309 hero_newstep_diag.doFloor();
14405 else --hero_newstep_diag;
14406 309 }
14407 else
14408 309 shiftdir = -1;
14409 642 }
14410
2/2
✓ Branch 0 taken 1902 times.
✓ Branch 1 taken 622 times.
2524 else if(walkable)
14411 {
14412 1902 do
14413 {
14414 1908 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14415 1908 execute(info);
14416
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1897 times.
1908 if(info.isUnwalkable())
14417 {
14418
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14419 {
14420 1 x.doRound();
14421 1 }
14422
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14423 {
14424
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14425 5 hero_newstep_diag.doFloor();
14426 else --hero_newstep_diag;
14427 5 }
14428 else
14429 5 shiftdir = -1;
14430 11 }
14431 1897 else break;
14432
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14433 11 while(shiftdir != -1);
14434 1902 break;
14435 }
14436 622 else break;
14437
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 309 times.
642 }
14438 642 while(shiftdir != -1);
14439 2833 }
14440 }
14441
14442 16580 move(down);
14443 16580 shiftdir=s;
14444
14445
2/2
✓ Branch 0 taken 14111 times.
✓ Branch 1 taken 2469 times.
16580 if(!walkable)
14446 {
14447
2/2
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1354 times.
2469 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14448 {
14449 1354 x = x.getInt();
14450 1354 y = y.getInt();
14451
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1354 times.
✓ Branch 2 taken 1354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 866 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 133 times.
✓ Branch 7 taken 1221 times.
1842 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14452
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
✓ Branch 2 taken 488 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 426 times.
488 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14453
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 426 times.
✗ Branch 3 not taken.
426 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14454 {
14455
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14456 133 sprite::move((zfix)-1,(zfix)0);
14457 133 }
14458
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1221 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✓ Branch 5 taken 866 times.
✓ Branch 6 taken 151 times.
✓ Branch 7 taken 1070 times.
2087 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14459
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 866 times.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 715 times.
✓ Branch 5 taken 151 times.
866 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14460
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151 times.
151 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14461 {
14462
4/8
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 151 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 151 times.
151 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14463 151 sprite::move((zfix)1,(zfix)0);
14464 151 }
14465 else
14466 {
14467 1070 pushing=push+1;
14468 }
14469 1354 }
14470 else
14471 {
14472 1115 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14473 }
14474 2469 }
14475
14476 16580 return;
14477 }
14478 }
14479
14480
6/6
✓ Branch 0 taken 23638 times.
✓ Branch 1 taken 72284 times.
✓ Branch 2 taken 22775 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 22768 times.
✓ Branch 5 taken 7 times.
95922 if(DrunkLeft()&&(holddir==-1||holddir==left))
14481 {
14482
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 23631 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
23631 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14483 {
14484 }
14485 else
14486 {
14487
3/6
✓ Branch 0 taken 23631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23631 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23631 times.
23631 if(charging==0 && spins==0 && action != sideswimattacking)
14488 {
14489 23631 dir=left;
14490 23631 }
14491 23631 sideswimdir = left;
14492
14493 23631 holddir=left;
14494
14495
3/4
✓ Branch 0 taken 3323 times.
✓ Branch 1 taken 20308 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3323 times.
23631 if(DrunkUp()&&shiftdir!=down)
14496 {
14497 3323 shiftdir=up;
14498 3323 }
14499
3/4
✓ Branch 0 taken 2542 times.
✓ Branch 1 taken 17766 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2542 times.
20308 else if(DrunkDown()&&shiftdir!=up)
14500 {
14501 2542 shiftdir=down;
14502 2542 }
14503 else
14504 {
14505 17766 shiftdir=-1;
14506 }
14507
14508 23631 do
14509 {
14510 26273 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14511
14512 26273 info = info || walkflag(x-hero_newstep,y+15,1,left);
14513
14514 26273 execute(info);
14515
14516
2/2
✓ Branch 0 taken 5021 times.
✓ Branch 1 taken 21252 times.
26273 if(info.isUnwalkable())
14517 {
14518
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 4758 times.
5021 if(x != x.getInt())
14519 {
14520 263 x.doRound();
14521 263 }
14522
2/2
✓ Branch 0 taken 2379 times.
✓ Branch 1 taken 2379 times.
4758 else if(hero_newstep > 1)
14523 {
14524
1/2
✓ Branch 0 taken 2379 times.
✗ Branch 1 not taken.
2379 if(hero_newstep != int32_t(hero_newstep)) //floor
14525 2379 hero_newstep = floor((double)hero_newstep);
14526 else --hero_newstep;
14527 2379 }
14528 else
14529 2379 break;
14530 2642 }
14531 21252 else walkable = true;
14532
2/2
✓ Branch 0 taken 2642 times.
✓ Branch 1 taken 21252 times.
23894 }
14533 23894 while(!walkable);
14534
14535 23631 int32_t s=shiftdir;
14536
14537
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 23631 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1405 times.
✓ Branch 7 taken 22226 times.
✓ Branch 8 taken 1382 times.
✓ Branch 9 taken 23 times.
✓ Branch 10 taken 1382 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1382 times.
✗ Branch 13 not taken.
23631 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14538 {
14539 1382 shiftdir=-1;
14540 1382 }
14541 else
14542 {
14543
2/2
✓ Branch 0 taken 19030 times.
✓ Branch 1 taken 3219 times.
22249 if(s==up)
14544 {
14545 3219 do
14546 {
14547 3740 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14548
14549 3740 execute(info);
14550
14551
2/2
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 2741 times.
3740 if(info.isUnwalkable())
14552 {
14553
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 956 times.
999 if(y != y.getInt())
14554 {
14555 43 y.doRound();
14556 43 }
14557
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 478 times.
956 else if(hero_newstep_diag > 1)
14558 {
14559
1/2
✓ Branch 0 taken 478 times.
✗ Branch 1 not taken.
478 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14560 478 hero_newstep_diag.doFloor();
14561 else --hero_newstep_diag;
14562 478 }
14563 else
14564 478 shiftdir = -1;
14565 999 }
14566
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 542 times.
2741 else if(walkable)
14567 {
14568 2199 do
14569 {
14570 2221 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14571 2221 execute(info);
14572
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2186 times.
2221 if(info.isUnwalkable())
14573 {
14574
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 if(y != y.getInt())
14575 {
14576 9 y.doRound();
14577 9 }
14578
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
14579 {
14580
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14581 13 hero_newstep_diag.doFloor();
14582 else --hero_newstep_diag;
14583 13 }
14584 else
14585 13 shiftdir = -1;
14586 35 }
14587 2186 else break;
14588
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 }
14589 35 while(shiftdir != -1);
14590 2199 break;
14591 }
14592 542 else break;
14593
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 478 times.
999 }
14594 999 while(shiftdir != -1);
14595 3219 }
14596
2/2
✓ Branch 0 taken 16549 times.
✓ Branch 1 taken 2481 times.
19030 else if(s==down)
14597 {
14598 2481 do
14599 {
14600 2937 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14601
14602 2937 execute(info);
14603
14604
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 2074 times.
2937 if(info.isUnwalkable())
14605 {
14606
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 814 times.
863 if(y != y.getInt())
14607 {
14608 49 y.doRound();
14609 49 }
14610
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 407 times.
814 else if(hero_newstep_diag > 1)
14611 {
14612
1/2
✓ Branch 0 taken 407 times.
✗ Branch 1 not taken.
407 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14613 407 hero_newstep_diag.doFloor();
14614 else --hero_newstep_diag;
14615 407 }
14616 else
14617 407 shiftdir = -1;
14618 863 }
14619
2/2
✓ Branch 0 taken 1701 times.
✓ Branch 1 taken 373 times.
2074 else if(walkable)
14620 {
14621 1701 do
14622 {
14623 1704 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14624 1704 execute(info);
14625
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1699 times.
1704 if(info.isUnwalkable())
14626 {
14627
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(y != y.getInt())
14628 {
14629 1 y.doRound();
14630 1 }
14631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14632 {
14633
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14634 2 hero_newstep_diag.doFloor();
14635 else --hero_newstep_diag;
14636 2 }
14637 else
14638 2 shiftdir = -1;
14639 5 }
14640 1699 else break;
14641
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
14642 5 while(shiftdir != -1);
14643 1701 break;
14644 }
14645 373 else break;
14646
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 407 times.
863 }
14647 863 while(shiftdir != -1);
14648 2481 }
14649 }
14650
14651 23631 move(left);
14652 23631 shiftdir=s;
14653
14654
2/2
✓ Branch 0 taken 21252 times.
✓ Branch 1 taken 2379 times.
23631 if(!walkable)
14655 {
14656
2/2
✓ Branch 0 taken 982 times.
✓ Branch 1 taken 1397 times.
2379 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14657 {
14658 1397 x = x.getInt();
14659 1397 y = y.getInt();
14660 1397 int32_t v1=bigHitbox?0:8;
14661 1397 int32_t v2=bigHitbox?8:12;
14662
14663
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1397 times.
✓ Branch 2 taken 1397 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1221 times.
✓ Branch 5 taken 176 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 1356 times.
1573 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
14664
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
✓ Branch 4 taken 135 times.
✓ Branch 5 taken 41 times.
176 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
14665
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
14666 {
14667
4/8
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
41 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
14668 41 sprite::move((zfix)0,(zfix)-1);
14669 41 }
14670
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1356 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1356 times.
✓ Branch 4 taken 135 times.
✓ Branch 5 taken 1221 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 1315 times.
2577 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
14671
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1221 times.
✓ Branch 4 taken 1180 times.
✓ Branch 5 taken 41 times.
1221 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
14672
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
14673 {
14674
4/8
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
41 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
14675 41 sprite::move((zfix)0,(zfix)1);
14676 41 }
14677 else
14678 {
14679 1315 pushing=push+1;
14680 }
14681 1397 }
14682 else
14683 {
14684 982 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14685
14686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 982 times.
982 if(action!=swimming)
14687 {
14688 982 }
14689 }
14690 2379 }
14691
14692 23631 return;
14693 }
14694 }
14695
14696
5/6
✓ Branch 0 taken 25313 times.
✓ Branch 1 taken 46978 times.
✓ Branch 2 taken 24460 times.
✓ Branch 3 taken 853 times.
✓ Branch 4 taken 24460 times.
✗ Branch 5 not taken.
72291 if(DrunkRight()&&(holddir==-1||holddir==right))
14697 {
14698
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 25313 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25313 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14699 {
14700 }
14701 else
14702 {
14703
3/6
✓ Branch 0 taken 25313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25313 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25313 times.
25313 if(charging==0 && spins==0 && action != sideswimattacking)
14704 {
14705 25313 dir=right;
14706 25313 }
14707 25313 sideswimdir = right;
14708
14709 25313 holddir=right;
14710
14711
3/4
✓ Branch 0 taken 3038 times.
✓ Branch 1 taken 22275 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3038 times.
25313 if(DrunkUp()&&shiftdir!=down)
14712 {
14713 3038 shiftdir=up;
14714 3038 }
14715
4/4
✓ Branch 0 taken 2814 times.
✓ Branch 1 taken 19461 times.
✓ Branch 2 taken 2812 times.
✓ Branch 3 taken 2 times.
22275 else if(DrunkDown()&&shiftdir!=up)
14716 {
14717 2812 shiftdir=down;
14718 2812 }
14719 else
14720 {
14721 19463 shiftdir=-1;
14722 }
14723
14724 25313 do
14725 {
14726 28072 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
14727
14728 28072 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
14729
14730 28072 execute(info);
14731
14732
2/2
✓ Branch 0 taken 5229 times.
✓ Branch 1 taken 22843 times.
28072 if(info.isUnwalkable())
14733 {
14734
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 5024 times.
5229 if(x != x.getInt())
14735 {
14736 205 x.doRound();
14737 205 }
14738
2/2
✓ Branch 0 taken 2554 times.
✓ Branch 1 taken 2470 times.
5024 else if(hero_newstep > 1)
14739 {
14740
1/2
✓ Branch 0 taken 2554 times.
✗ Branch 1 not taken.
2554 if(hero_newstep != int32_t(hero_newstep)) //floor
14741 2554 hero_newstep = floor((double)hero_newstep);
14742 else --hero_newstep;
14743 2554 }
14744 else
14745 2470 break;
14746 2759 }
14747 22843 else walkable = true;
14748
2/2
✓ Branch 0 taken 2759 times.
✓ Branch 1 taken 22843 times.
25602 }
14749 25602 while(!walkable);
14750
14751 25313 int32_t s=shiftdir;
14752
14753
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 25313 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2440 times.
✓ Branch 7 taken 22873 times.
✓ Branch 8 taken 2422 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 2422 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2422 times.
✗ Branch 13 not taken.
25313 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14754 {
14755 2422 shiftdir=-1;
14756 2422 }
14757 else
14758 {
14759
2/2
✓ Branch 0 taken 20116 times.
✓ Branch 1 taken 2775 times.
22891 if(s==up)
14760 {
14761 2775 do
14762 {
14763 3075 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14764
14765 3075 execute(info);
14766
14767
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 2515 times.
3075 if(info.isUnwalkable())
14768 {
14769
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 520 times.
560 if(y != y.getInt())
14770 {
14771 40 y.doRound();
14772 40 }
14773
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 260 times.
520 else if(hero_newstep_diag > 1)
14774 {
14775
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14776 260 hero_newstep_diag.doFloor();
14777 else --hero_newstep_diag;
14778 260 }
14779 else
14780 260 shiftdir = -1;
14781 560 }
14782
2/2
✓ Branch 0 taken 2143 times.
✓ Branch 1 taken 372 times.
2515 else if(walkable)
14783 {
14784 2143 do
14785 {
14786 2163 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14787 2163 execute(info);
14788
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 2132 times.
2163 if(info.isUnwalkable())
14789 {
14790
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 if(y != y.getInt())
14791 {
14792 9 y.doRound();
14793 9 }
14794
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(hero_newstep_diag > 1)
14795 {
14796
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14797 11 hero_newstep_diag.doFloor();
14798 else --hero_newstep_diag;
14799 11 }
14800 else
14801 11 shiftdir = -1;
14802 31 }
14803 2132 else break;
14804
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 11 times.
31 }
14805 31 while(shiftdir != -1);
14806 2143 break;
14807 }
14808 372 else break;
14809
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 260 times.
560 }
14810 560 while(shiftdir != -1);
14811 2775 }
14812
2/2
✓ Branch 0 taken 17451 times.
✓ Branch 1 taken 2665 times.
20116 else if(s==down)
14813 {
14814 2665 do
14815 {
14816 3207 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14817
14818 3207 execute(info);
14819
14820
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 2187 times.
3207 if(info.isUnwalkable())
14821 {
14822
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 958 times.
1020 if(y != y.getInt())
14823 {
14824 62 y.doRound();
14825 62 }
14826
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 478 times.
958 else if(hero_newstep_diag > 1)
14827 {
14828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14829 480 hero_newstep_diag.doFloor();
14830 else --hero_newstep_diag;
14831 480 }
14832 else
14833 478 shiftdir = -1;
14834 1020 }
14835
2/2
✓ Branch 0 taken 1825 times.
✓ Branch 1 taken 362 times.
2187 else if(walkable)
14836 {
14837 1825 do
14838 {
14839 1836 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
14840 1836 execute(info);
14841
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1818 times.
1836 if(info.isUnwalkable())
14842 {
14843
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 14 times.
18 if(y != y.getInt())
14844 {
14845 4 y.doRound();
14846 4 }
14847
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
14 else if(hero_newstep_diag > 1)
14848 {
14849
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14850 7 hero_newstep_diag.doFloor();
14851 else --hero_newstep_diag;
14852 7 }
14853 else
14854 7 shiftdir = -1;
14855 18 }
14856 1818 else break;
14857
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7 times.
18 }
14858 18 while(shiftdir != -1);
14859 1825 break;
14860 }
14861 362 else break;
14862
2/2
✓ Branch 0 taken 542 times.
✓ Branch 1 taken 478 times.
1020 }
14863 1020 while(shiftdir != -1);
14864 2665 }
14865 }
14866
14867 25313 move(right);
14868 25313 shiftdir=s;
14869
14870
2/2
✓ Branch 0 taken 22843 times.
✓ Branch 1 taken 2470 times.
25313 if(!walkable)
14871 {
14872
2/2
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 1684 times.
2470 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14873 {
14874 1684 x = x.getInt();
14875 1684 y = y.getInt();
14876 1684 int32_t v1=bigHitbox?0:8;
14877 1684 int32_t v2=bigHitbox?8:12;
14878
14879
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 1684 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1558 times.
✓ Branch 5 taken 126 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1636 times.
1810 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14880
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 48 times.
126 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
14881
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
48 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14882 {
14883
4/8
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48 times.
48 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
14884 48 sprite::move((zfix)0,(zfix)-1);
14885 48 }
14886
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
✓ Branch 2 taken 1636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 1558 times.
✓ Branch 6 taken 59 times.
✓ Branch 7 taken 1577 times.
3194 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14887
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1558 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 1499 times.
✓ Branch 5 taken 59 times.
1558 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
14888
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14889 {
14890
4/8
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 59 times.
59 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
14891 59 sprite::move((zfix)0,(zfix)1);
14892 59 }
14893 else
14894 {
14895 1577 pushing=push+1;
14896 1577 z3step=2;
14897 }
14898 1684 }
14899 else
14900 {
14901 786 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14902
14903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if(action!=swimming)
14904 {
14905 786 }
14906 }
14907 2470 }
14908
14909 25313 return;
14910 }
14911 }
14912 46978 }
14913 else
14914 {
14915
6/6
✓ Branch 0 taken 40961 times.
✓ Branch 1 taken 281883 times.
✓ Branch 2 taken 40073 times.
✓ Branch 3 taken 888 times.
✓ Branch 4 taken 9351 times.
✓ Branch 5 taken 30722 times.
322844 if(DrunkUp()&&(holddir==-1||holddir==up))
14916 {
14917
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 31610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
31610 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14918 {
14919 }
14920 else
14921 {
14922
2/4
✓ Branch 0 taken 31610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31610 times.
31610 if(charging==0 && spins==0)
14923 {
14924 31610 dir=up;
14925 31610 }
14926
14927 31610 holddir=up;
14928
14929
4/4
✓ Branch 0 taken 4192 times.
✓ Branch 1 taken 27418 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 4187 times.
31610 if(DrunkRight()&&shiftdir!=left)
14930 {
14931 4187 shiftdir=right;
14932 4187 }
14933
4/4
✓ Branch 0 taken 3311 times.
✓ Branch 1 taken 24112 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 3306 times.
27423 else if(DrunkLeft()&&shiftdir!=right)
14934 {
14935 3306 shiftdir=left;
14936 3306 }
14937 else
14938 {
14939 24117 shiftdir=-1;
14940 }
14941
14942 //walkable if Ladder can be placed or is already placed vertically
14943
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 15125 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16354 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16354 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
31610 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14944 {
14945 16354 walkable=false;
14946 16354 }
14947 else
14948 {
14949 15256 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14950
14951
2/2
✓ Branch 0 taken 9300 times.
✓ Branch 1 taken 5956 times.
15256 if(x.getInt() & 7)
14952 9300 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
14953 else
14954 5956 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
14955
14956 15256 execute(info);
14957
14958
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 14275 times.
15256 if(info.isUnwalkable())
14959 {
14960
2/2
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 51 times.
981 if(z3step==2)
14961 {
14962 930 z3step=1;
14963 930 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14964
14965
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 692 times.
930 if(x.getInt()&7)
14966 692 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
14967 else
14968 238 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
14969
14970 930 execute(info);
14971
14972
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 82 times.
930 if(info.isUnwalkable())
14973 {
14974 848 walkable = false;
14975 848 }
14976 else
14977 {
14978 82 walkable=true;
14979 }
14980 930 }
14981 else
14982 {
14983 51 walkable=false;
14984 }
14985 981 }
14986 else
14987 {
14988 14275 walkable = true;
14989 }
14990 }
14991
14992 31610 int32_t s=shiftdir;
14993
14994
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31610 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14995 {
14996 shiftdir=-1;
14997 }
14998 else
14999 {
15000
2/2
✓ Branch 0 taken 3306 times.
✓ Branch 1 taken 28304 times.
31610 if(s==left)
15001 {
15002 3306 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15003 3306 execute(info);
15004
15005
2/2
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 2880 times.
3306 if(info.isUnwalkable())
15006 {
15007 426 shiftdir=-1;
15008 426 }
15009
2/2
✓ Branch 0 taken 1154 times.
✓ Branch 1 taken 1726 times.
2880 else if(walkable)
15010 {
15011 1726 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15012 1726 execute(info);
15013
2/2
✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 3 times.
1726 if(info.isUnwalkable())
15014 {
15015 3 shiftdir=-1;
15016 3 }
15017 1726 }
15018 3306 }
15019
2/2
✓ Branch 0 taken 24117 times.
✓ Branch 1 taken 4187 times.
28304 else if(s==right)
15020 {
15021 4187 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15022 4187 execute(info);
15023
15024
2/2
✓ Branch 0 taken 662 times.
✓ Branch 1 taken 3525 times.
4187 if(info.isUnwalkable())
15025 {
15026 662 shiftdir=-1;
15027 662 }
15028
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 1925 times.
3525 else if(walkable)
15029 {
15030 1925 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15031 1925 execute(info);
15032
15033
2/2
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 2 times.
1925 if(info.isUnwalkable())
15034 {
15035 2 shiftdir=-1;
15036 2 }
15037 1925 }
15038 4187 }
15039 }
15040
15041 31610 move(up);
15042 31610 shiftdir=s;
15043
15044
2/2
✓ Branch 0 taken 14357 times.
✓ Branch 1 taken 17253 times.
31610 if(!walkable)
15045 {
15046
2/2
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 13985 times.
17253 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15047 {
15048
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 13985 times.
✓ Branch 2 taken 13985 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 425 times.
✓ Branch 5 taken 13560 times.
✓ Branch 6 taken 117 times.
✓ Branch 7 taken 13868 times.
27545 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15049
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13560 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13560 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 13497 times.
13560 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15050
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13497 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13497 times.
13497 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15051 {
15052
5/8
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 109 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 117 times.
117 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15053 117 sprite::move((zfix)-1,(zfix)0);
15054 117 }
15055 else
15056 {
15057
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 13868 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13868 times.
✓ Branch 4 taken 13443 times.
✓ Branch 5 taken 425 times.
✓ Branch 6 taken 94 times.
✓ Branch 7 taken 13774 times.
14293 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15058
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 425 times.
✓ Branch 4 taken 331 times.
✓ Branch 5 taken 94 times.
425 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15059
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
94 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15060 {
15061
5/8
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 94 times.
94 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15062 94 sprite::move((zfix)1,(zfix)0);
15063 94 }
15064 else
15065 {
15066 13774 pushing=push+1;
15067 }
15068 }
15069
15070 13985 z3step=2;
15071 13985 }
15072 else
15073 {
15074 3268 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15075 3268 z3step=2;
15076 }
15077 17253 }
15078
15079 31610 return;
15080 }
15081 }
15082
15083
6/6
✓ Branch 0 taken 26490 times.
✓ Branch 1 taken 264744 times.
✓ Branch 2 taken 25806 times.
✓ Branch 3 taken 684 times.
✓ Branch 4 taken 19603 times.
✓ Branch 5 taken 6203 times.
291234 if(DrunkDown()&&(holddir==-1||holddir==down))
15084 {
15085
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20287 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15086 {
15087 }
15088 else
15089 {
15090
2/4
✓ Branch 0 taken 20287 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20287 times.
✗ Branch 3 not taken.
20287 if(charging==0 && spins==0)
15091 {
15092 20287 dir=down;
15093 20287 }
15094
15095 20287 holddir=down;
15096
15097
4/4
✓ Branch 0 taken 3001 times.
✓ Branch 1 taken 17286 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2998 times.
20287 if(DrunkRight()&&shiftdir!=left)
15098 {
15099 2998 shiftdir=right;
15100 2998 }
15101
4/4
✓ Branch 0 taken 2782 times.
✓ Branch 1 taken 14507 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2781 times.
17289 else if(DrunkLeft()&&shiftdir!=right)
15102 {
15103 2781 shiftdir=left;
15104 2781 }
15105 else
15106 {
15107 14508 shiftdir=-1;
15108 }
15109
15110 //bool walkable;
15111
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 11142 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
20287 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15112 {
15113 9145 walkable=false;
15114 9145 }
15115 else
15116 {
15117 11142 info = walkflag(x,y+15+z3step,2,down);
15118
15119
2/2
✓ Branch 0 taken 6974 times.
✓ Branch 1 taken 4168 times.
11142 if(x.getInt()&7)
15120 6974 info = info || walkflag(x+16,y+15+z3step,1,down);
15121 else
15122 4168 info = info || walkflagMBlock(x+16, y+15+z3step);
15123
15124 11142 execute(info);
15125
15126
2/2
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 10295 times.
11142 if(info.isUnwalkable())
15127 {
15128
2/2
✓ Branch 0 taken 815 times.
✓ Branch 1 taken 32 times.
847 if(z3step==2)
15129 {
15130 815 z3step=1;
15131 815 info = walkflag(x,y+15+z3step,2,down);
15132
15133
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 198 times.
815 if(x.getInt()&7)
15134 617 info = info || walkflag(x+16,y+15+z3step,1,down);
15135 else
15136 198 info = info || walkflagMBlock(x+16, y+15+z3step);
15137
15138 815 execute(info);
15139
15140
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 46 times.
815 if(info.isUnwalkable())
15141 {
15142 769 walkable = false;
15143 769 }
15144 else
15145 {
15146 46 walkable=true;
15147 }
15148 815 }
15149 else
15150 {
15151 32 walkable=false;
15152 }
15153 847 }
15154 else
15155 {
15156 10295 walkable = true;
15157 }
15158 }
15159
15160 20287 int32_t s=shiftdir;
15161
15162
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20287 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15163 {
15164 shiftdir=-1;
15165 }
15166 else
15167 {
15168
2/2
✓ Branch 0 taken 2781 times.
✓ Branch 1 taken 17506 times.
20287 if(s==left)
15169 {
15170 2781 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15171 2781 execute(info);
15172
15173
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 2501 times.
2781 if(info.isUnwalkable())
15174 {
15175 280 shiftdir=-1;
15176 280 }
15177
2/2
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 1255 times.
2501 else if(walkable)
15178 {
15179 1255 info = walkflag(x-1,y+16,1,left);
15180 1255 execute(info);
15181
15182
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 4 times.
1255 if(info.isUnwalkable())
15183 {
15184 4 shiftdir=-1;
15185 4 }
15186 1255 }
15187 2781 }
15188
2/2
✓ Branch 0 taken 14508 times.
✓ Branch 1 taken 2998 times.
17506 else if(s==right)
15189 {
15190 2998 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15191 2998 execute(info);
15192
15193
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 2723 times.
2998 if(info.isUnwalkable())
15194 {
15195 275 shiftdir=-1;
15196 275 }
15197
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 1806 times.
2723 else if(walkable)
15198 {
15199 1806 info = walkflag(x+16,y+16,1,right);
15200 1806 execute(info);
15201
15202
2/2
✓ Branch 0 taken 1803 times.
✓ Branch 1 taken 3 times.
1806 if(info.isUnwalkable())
15203 {
15204 3 shiftdir=-1;
15205 3 }
15206 1806 }
15207 2998 }
15208 }
15209
15210 20287 move(down);
15211 20287 shiftdir=s;
15212
15213
2/2
✓ Branch 0 taken 10341 times.
✓ Branch 1 taken 9946 times.
20287 if(!walkable)
15214 {
15215
2/2
✓ Branch 0 taken 2326 times.
✓ Branch 1 taken 7620 times.
9946 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15216 {
15217
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7620 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7620 times.
✓ Branch 4 taken 1995 times.
✓ Branch 5 taken 5625 times.
✓ Branch 6 taken 74 times.
✓ Branch 7 taken 7546 times.
13245 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15218
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5625 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5625 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 5465 times.
5625 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15219
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5465 times.
5465 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15220 {
15221
4/8
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
74 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15222 74 sprite::move((zfix)-1,(zfix)0);
15223 74 }
15224
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7546 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7546 times.
✓ Branch 4 taken 5551 times.
✓ Branch 5 taken 1995 times.
✓ Branch 6 taken 93 times.
✓ Branch 7 taken 7453 times.
9541 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15225
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1995 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1995 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 93 times.
1995 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15226
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
93 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15227 {
15228
5/8
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 79 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 93 times.
93 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15229 93 sprite::move((zfix)1,(zfix)0);
15230 93 }
15231 else //if(shiftdir==-1)
15232 {
15233 7453 pushing=push+1;
15234
15235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7453 times.
7453 if(action!=swimming)
15236 {
15237 7453 }
15238 }
15239
15240 7620 z3step=2;
15241 7620 }
15242 else
15243 {
15244 2326 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15245
15246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2326 times.
2326 if(action!=swimming)
15247 {
15248 2326 }
15249
15250 2326 z3step=2;
15251 }
15252 9946 }
15253
15254 20287 return;
15255 }
15256 }
15257
15258
6/6
✓ Branch 0 taken 75469 times.
✓ Branch 1 taken 195478 times.
✓ Branch 2 taken 73131 times.
✓ Branch 3 taken 2338 times.
✓ Branch 4 taken 73064 times.
✓ Branch 5 taken 67 times.
270947 if(DrunkLeft()&&(holddir==-1||holddir==left))
15259 {
15260
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 75402 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
75402 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15261 {
15262 }
15263 else
15264 {
15265
2/4
✓ Branch 0 taken 75402 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75402 times.
75402 if(charging==0 && spins==0)
15266 {
15267 75402 dir=left;
15268 75402 }
15269
15270 75402 holddir=left;
15271
15272
4/4
✓ Branch 0 taken 3996 times.
✓ Branch 1 taken 71406 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3995 times.
75402 if(DrunkUp()&&shiftdir!=down)
15273 {
15274 3995 shiftdir=up;
15275 3995 }
15276
3/4
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 68335 times.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
71407 else if(DrunkDown()&&shiftdir!=up)
15277 {
15278 3072 shiftdir=down;
15279 3072 }
15280 else
15281 {
15282 68335 shiftdir=-1;
15283 }
15284
15285 //bool walkable;
15286 75402 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15287
15288
2/2
✓ Branch 0 taken 38385 times.
✓ Branch 1 taken 37017 times.
75402 if(y.getInt()&7)
15289 37017 info = info || walkflag(x-z3step,y+16,1,left);
15290
15291 75402 execute(info);
15292
15293
2/2
✓ Branch 0 taken 7250 times.
✓ Branch 1 taken 68152 times.
75402 if(info.isUnwalkable())
15294 {
15295
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 221 times.
7250 if(z3step==2)
15296 {
15297 7029 z3step=1;
15298 7029 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15299
15300
2/2
✓ Branch 0 taken 4599 times.
✓ Branch 1 taken 2430 times.
7029 if(y.getInt()&7)
15301 4599 info = info || walkflag(x-z3step,y+16,1,left);
15302
15303 7029 execute(info);
15304
15305
2/2
✓ Branch 0 taken 6789 times.
✓ Branch 1 taken 240 times.
7029 if(info.isUnwalkable())
15306 {
15307 6789 walkable = false;
15308 6789 }
15309 else
15310 {
15311 240 walkable=true;
15312 }
15313 7029 }
15314 else
15315 {
15316 221 walkable=false;
15317 }
15318 7250 }
15319 else
15320 {
15321 68152 walkable = true;
15322 }
15323
15324 75402 int32_t s=shiftdir;
15325
15326
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 75402 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 19068 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
75402 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15327 {
15328 56334 shiftdir=-1;
15329 56334 }
15330 else
15331 {
15332
2/2
✓ Branch 0 taken 16364 times.
✓ Branch 1 taken 2704 times.
19068 if(s==up)
15333 {
15334 2704 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15335 2704 execute(info);
15336
15337
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 2501 times.
2704 if(info.isUnwalkable())
15338 {
15339 203 shiftdir=-1;
15340 203 }
15341
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 2347 times.
2501 else if(walkable)
15342 {
15343 2347 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15344 2347 execute(info);
15345
15346
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 4 times.
2347 if(info.isUnwalkable())
15347 {
15348 4 shiftdir=-1;
15349 4 }
15350 2347 }
15351 2704 }
15352
2/2
✓ Branch 0 taken 13853 times.
✓ Branch 1 taken 2511 times.
16364 else if(s==down)
15353 {
15354 2511 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15355 2511 execute(info);
15356
15357
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 2225 times.
2511 if(info.isUnwalkable())
15358 {
15359 286 shiftdir=-1;
15360 286 }
15361
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 2043 times.
2225 else if(walkable)
15362 {
15363 2043 info = walkflag(x-1,y+16,1,down);
15364 2043 execute(info);
15365
15366
2/2
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 2 times.
2043 if(info.isUnwalkable())
15367 {
15368 2 shiftdir=-1;
15369 2 }
15370 2043 }
15371 2511 }
15372 }
15373
15374 75402 move(left);
15375 75402 shiftdir=s;
15376
15377
2/2
✓ Branch 0 taken 68392 times.
✓ Branch 1 taken 7010 times.
75402 if(!walkable)
15378 {
15379
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 6390 times.
7010 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15380 {
15381 6390 int32_t v1=bigHitbox?0:8;
15382 6390 int32_t v2=bigHitbox?8:12;
15383
15384
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6390 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6390 times.
✓ Branch 4 taken 5167 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 596 times.
✓ Branch 7 taken 5794 times.
7613 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15385
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1223 times.
✓ Branch 2 taken 1223 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 627 times.
✓ Branch 5 taken 596 times.
1223 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15386
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 596 times.
596 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15387 {
15388
5/8
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 515 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 596 times.
596 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15389 596 sprite::move((zfix)0,(zfix)-1);
15390 596 }
15391
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5794 times.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 627 times.
✓ Branch 5 taken 5167 times.
✓ Branch 6 taken 196 times.
✓ Branch 7 taken 5598 times.
10961 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15392
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5167 times.
✓ Branch 4 taken 4971 times.
✓ Branch 5 taken 196 times.
5167 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15393
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
196 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15394 {
15395
6/8
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 163 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 195 times.
196 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15396 195 sprite::move((zfix)0,(zfix)1);
15397 196 }
15398 else //if(shiftdir==-1)
15399 {
15400 5598 pushing=push+1;
15401
15402
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5589 times.
5598 if(action!=swimming)
15403 {
15404 5589 }
15405 }
15406
15407 6390 z3step=2;
15408 6390 }
15409 else
15410 {
15411 620 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15412
15413
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 614 times.
620 if(action!=swimming)
15414 {
15415 614 }
15416
15417 620 z3step=2;
15418 }
15419 7010 }
15420
15421 75402 return;
15422 }
15423 }
15424
15425
5/6
✓ Branch 0 taken 86909 times.
✓ Branch 1 taken 108636 times.
✓ Branch 2 taken 84350 times.
✓ Branch 3 taken 2559 times.
✓ Branch 4 taken 84350 times.
✗ Branch 5 not taken.
195545 if(DrunkRight()&&(holddir==-1||holddir==right))
15426 {
15427
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 86909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
86909 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15428 {
15429 }
15430 else
15431 {
15432
2/4
✓ Branch 0 taken 86909 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 86909 times.
86909 if(charging==0 && spins==0)
15433 {
15434 86909 dir=right;
15435 86909 }
15436
15437 86909 holddir=right;
15438
15439
4/4
✓ Branch 0 taken 5347 times.
✓ Branch 1 taken 81562 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 5346 times.
86909 if(DrunkUp()&&shiftdir!=down)
15440 {
15441 5346 shiftdir=up;
15442 5346 }
15443
3/4
✓ Branch 0 taken 3131 times.
✓ Branch 1 taken 78432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3131 times.
81563 else if(DrunkDown()&&shiftdir!=up)
15444 {
15445 3131 shiftdir=down;
15446 3131 }
15447 else
15448 {
15449 78432 shiftdir=-1;
15450 }
15451
15452 //bool walkable;
15453 86909 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15454
15455
2/2
✓ Branch 0 taken 42949 times.
✓ Branch 1 taken 43960 times.
86909 if(y.getInt()&7)
15456 43960 info = info || walkflag(x+15+z3step,y+16,1,right);
15457
15458 86909 execute(info);
15459
15460
2/2
✓ Branch 0 taken 9092 times.
✓ Branch 1 taken 77817 times.
86909 if(info.isUnwalkable())
15461 {
15462
2/2
✓ Branch 0 taken 8854 times.
✓ Branch 1 taken 238 times.
9092 if(z3step==2)
15463 {
15464 8854 z3step=1;
15465 8854 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15466
15467
2/2
✓ Branch 0 taken 5958 times.
✓ Branch 1 taken 2896 times.
8854 if(y.getInt()&7)
15468 5958 info = info || walkflag(x+15+z3step,y+16,1,right);
15469
15470 8854 execute(info);
15471
15472
2/2
✓ Branch 0 taken 8517 times.
✓ Branch 1 taken 337 times.
8854 if(info.isUnwalkable())
15473 {
15474 8517 walkable = false;
15475 8517 }
15476 else
15477 {
15478 337 walkable=true;
15479 }
15480 8854 }
15481 else
15482 {
15483 238 walkable=false;
15484 }
15485 9092 }
15486 else
15487 {
15488 77817 walkable = true;
15489 }
15490
15491 86909 int32_t s=shiftdir;
15492
15493
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 86909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 20983 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
86909 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15494 {
15495 65926 shiftdir=-1;
15496 65926 }
15497 else
15498 {
15499
2/2
✓ Branch 0 taken 17399 times.
✓ Branch 1 taken 3584 times.
20983 if(s==up)
15500 {
15501 3584 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15502 3584 execute(info);
15503
15504
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 3335 times.
3584 if(info.isUnwalkable())
15505 {
15506 249 shiftdir=-1;
15507 249 }
15508
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 3153 times.
3335 else if(walkable)
15509 {
15510 3153 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15511 3153 execute(info);
15512
15513
2/2
✓ Branch 0 taken 3149 times.
✓ Branch 1 taken 4 times.
3153 if(info.isUnwalkable())
15514 {
15515 4 shiftdir=-1;
15516 4 }
15517 3153 }
15518 3584 }
15519
2/2
✓ Branch 0 taken 14745 times.
✓ Branch 1 taken 2654 times.
17399 else if(s==down)
15520 {
15521 2654 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15522 2654 execute(info);
15523
15524
2/2
✓ Branch 0 taken 329 times.
✓ Branch 1 taken 2325 times.
2654 if(info.isUnwalkable())
15525 {
15526 329 shiftdir=-1;
15527 329 }
15528
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 2167 times.
2325 else if(walkable)
15529 {
15530 2167 info = walkflag(x+16,y+16,1,down);
15531 2167 execute(info);
15532
15533
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 1 times.
2167 if(info.isUnwalkable())
15534 {
15535 1 shiftdir=-1;
15536 1 }
15537 2167 }
15538 2654 }
15539 }
15540
15541 86909 move(right);
15542 86909 shiftdir=s;
15543
15544
2/2
✓ Branch 0 taken 78154 times.
✓ Branch 1 taken 8755 times.
86909 if(!walkable)
15545 {
15546
2/2
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 7921 times.
8755 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15547 {
15548 7921 int32_t v1=bigHitbox?0:8;
15549 7921 int32_t v2=bigHitbox?8:12;
15550
15551 23763 info = !walkflag(x+16,y+v1,1,right)&&
15552 15842 !walkflag(x+16,y+v2,1,right)&&
15553 7921 walkflag(x+16,y+15,1,right);
15554
15555 //do NOT execute these
15556
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 7035 times.
7921 if(info.isUnwalkable())
15557 {
15558
6/8
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 865 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 885 times.
886 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15559 885 sprite::move((zfix)0,(zfix)-1);
15560 886 }
15561 else
15562 {
15563 21105 info = walkflag(x+16,y+v1, 1,right)&&
15564 14070 !walkflag(x+16,y+v2-1,1,right)&&
15565 7035 !walkflag(x+16,y+15, 1,right);
15566
15567
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 6772 times.
7035 if(info.isUnwalkable())
15568 {
15569
5/8
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 263 times.
263 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15570 263 sprite::move((zfix)0,(zfix)1);
15571 263 }
15572 else //if(shiftdir==-1)
15573 {
15574 6772 pushing=push+1;
15575 6772 z3step=2;
15576
15577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6772 times.
6772 if(action!=swimming)
15578 {
15579 6772 }
15580 }
15581 }
15582
15583 7921 z3step=2;
15584 7921 }
15585 else
15586 {
15587 834 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15588
15589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834 times.
834 if(action!=swimming)
15590 {
15591 834 }
15592
15593 834 z3step=2;
15594 }
15595 8755 }
15596
15597 86909 return;
15598 }
15599 }
15600 }
15601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 155614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155614 if(shield_forcedir > -1 && action != rafting)
15602 dir = shield_forcedir;
15603 155614 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15604 155614 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15605 155614 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15606 155614 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15607 155614 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15608
15609
8/12
✓ Branch 0 taken 45639 times.
✓ Branch 1 taken 109975 times.
✓ Branch 2 taken 45639 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 45639 times.
✓ Branch 6 taken 45639 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42856 times.
✓ Branch 9 taken 2783 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 42856 times.
155614 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15610 {
15611
7/12
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 42850 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
42856 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15612 {
15613 //action=swimming;
15614
2/12
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15615 {
15616 hopclk = 0xFF;
15617 }
15618 3 }
15619 42856 }
15620
15621 155614 return;
15622 } //endif (LTTPWALK)
15623 1151264 temp_step = hero_newstep;
15624 1151264 temp_x = x;
15625 1151264 temp_y = y;
15626
15627
7/8
✓ Branch 0 taken 856026 times.
✓ Branch 1 taken 295238 times.
✓ Branch 2 taken 844014 times.
✓ Branch 3 taken 12012 times.
✓ Branch 4 taken 6490 times.
✓ Branch 5 taken 849536 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6490 times.
1151264 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15628 {
15629
2/4
✓ Branch 0 taken 6490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6490 times.
6490 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15630 goto LEFTRIGHT_NEWMOVE;
15631 6490 else goto LEFTRIGHT_OLDMOVE;
15632 }
15633
15634 // make it easier to get in left & right doors
15635
15636 //ignore ladder for this part. sigh sigh sigh -DD
15637 1144774 oldladderx = ladderx;
15638 1144774 oldladdery = laddery;
15639
2/4
✓ Branch 0 taken 1144774 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1144774 times.
1144774 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15640 {
15641 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
15642 {
15643 do
15644 {
15645 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
15646 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
15647
15648 if(info.isUnwalkable())
15649 {
15650 if(temp_x != int32_t(temp_x))
15651 {
15652 temp_x = floor((double)temp_x);
15653 }
15654 else if(temp_step > 1)
15655 {
15656 if(temp_step != int32_t(temp_step)) //floor
15657 temp_step = floor((double)temp_step);
15658 else --temp_step;
15659 }
15660 else
15661 break;
15662 }
15663 }
15664 while(info.isUnwalkable());
15665
15666 if(!info.isUnwalkable())
15667 {
15668 x = temp_x;
15669 y = temp_y;
15670 hero_newstep = temp_step;
15671 //ONLY process the side-effects of the above walkflag if Hero will actually move
15672 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
15673 execute(info);
15674 move(left);
15675 return;
15676 }
15677 temp_x = x;
15678 temp_y = y;
15679 temp_step = hero_newstep;
15680 }
15681
15682 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
15683 {
15684 do
15685 {
15686 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
15687 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15688
15689 if(info.isUnwalkable())
15690 {
15691 if(temp_x != int32_t(temp_x))
15692 {
15693 temp_x = floor((double)temp_x);
15694 }
15695 else if(temp_step > 1)
15696 {
15697 if(temp_step != int32_t(temp_step)) //floor
15698 temp_step = floor((double)temp_step);
15699 else --temp_step;
15700 }
15701 else
15702 break;
15703 }
15704 }
15705 while(info.isUnwalkable());
15706
15707 if(!info.isUnwalkable())
15708 {
15709 x = temp_x;
15710 y = temp_y;
15711 hero_newstep = temp_step;
15712 execute(info);
15713 move(right);
15714 return;
15715 }
15716 temp_x = x;
15717 temp_y = y;
15718 temp_step = hero_newstep;
15719 }
15720
15721 ladderx = oldladderx;
15722 laddery = oldladdery;
15723
15724 if(DrunkUp())
15725 {
15726 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15727 {
15728 if(dir!=up && dir!=down)
15729 {
15730 if(xoff>2&&xoff<6)
15731 {
15732 move(dir);
15733 }
15734 else if(xoff>=6)
15735 {
15736 move(right);
15737 }
15738 else if(xoff>=1)
15739 {
15740 move(left);
15741 }
15742 }
15743 else
15744 {
15745 if(xoff>=4)
15746 {
15747 move(right);
15748 }
15749 else if(xoff<4)
15750 {
15751 move(left);
15752 }
15753 }
15754 }
15755 else
15756 {
15757 do
15758 {
15759 if(action==swimming || IsSideSwim() || action == swimhit)
15760 {
15761 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15762
15763 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
15764 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
15765 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
15766 info.setUnwalkable(true);
15767 }
15768 else
15769 {
15770 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15771 if(x.getInt() & 7)
15772 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
15773 else
15774 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15775 }
15776
15777 if(info.isUnwalkable())
15778 {
15779 if(temp_y != int32_t(temp_y))
15780 {
15781 temp_y = floor((double)temp_y);
15782 }
15783 else if(temp_step > 1)
15784 {
15785 if(temp_step != int32_t(temp_step)) //floor
15786 temp_step = floor((double)temp_step);
15787 else --temp_step;
15788 }
15789 else
15790 break;
15791 }
15792 }
15793 while(info.isUnwalkable());
15794
15795 execute(info);
15796
15797 if(!info.isUnwalkable())
15798 {
15799 x = temp_x;
15800 y = temp_y;
15801 hero_newstep = temp_step;
15802 move(up);
15803 return;
15804 }
15805
15806 if(!DrunkLeft() && !DrunkRight())
15807 {
15808 if(NO_GRIDLOCK)
15809 {
15810 x = x.getInt();
15811 y = y.getInt();
15812 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15813 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15814 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15815 {
15816 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15817 sprite::move((zfix)-1,(zfix)0);
15818 }
15819 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15820 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15821 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15822 {
15823 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15824 sprite::move((zfix)1,(zfix)0);
15825 }
15826 else
15827 {
15828 pushing=push+1;
15829 }
15830 }
15831 else pushing=push+1;
15832
15833 if(charging==0 && spins==0)
15834 {
15835 dir=up;
15836 }
15837
15838 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15839 {
15840 herostep();
15841 }
15842
15843 return;
15844 }
15845 else
15846 {
15847 goto LEFTRIGHT_NEWMOVE;
15848 }
15849 }
15850
15851 return;
15852 }
15853
15854 if(DrunkDown())
15855 {
15856 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15857 {
15858 if(dir!=up && dir!=down)
15859 {
15860 if(xoff>2&&xoff<6)
15861 {
15862 move(dir);
15863 }
15864 else if(xoff>=6)
15865 {
15866 move(right);
15867 }
15868 else if(xoff>=1)
15869 {
15870 move(left);
15871 }
15872 }
15873 else
15874 {
15875 if(xoff>=4)
15876 {
15877 move(right);
15878 }
15879 else if(xoff<4)
15880 {
15881 move(left);
15882 }
15883 }
15884 }
15885 else
15886 {
15887 do
15888 {
15889 if(action==swimming || IsSideSwim() || action == swimhit)
15890 {
15891 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15892
15893 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
15894 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
15895 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
15896 info.setUnwalkable(true);
15897 }
15898 else
15899 {
15900 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15901 if(x.getInt() & 7)
15902 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
15903 else
15904 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15905 }
15906
15907 if(info.isUnwalkable())
15908 {
15909 if(temp_y != int32_t(temp_y))
15910 {
15911 temp_y = floor((double)temp_y);
15912 }
15913 else if(temp_step > 1)
15914 {
15915 if(temp_step != int32_t(temp_step)) //floor
15916 temp_step = floor((double)temp_step);
15917 else --temp_step;
15918 }
15919 else
15920 break;
15921 }
15922 }
15923 while(info.isUnwalkable());
15924
15925 execute(info);
15926
15927 if(!info.isUnwalkable())
15928 {
15929 x = temp_x;
15930 y = temp_y;
15931 hero_newstep = temp_step;
15932 move(down);
15933 return;
15934 }
15935
15936 if(!DrunkLeft() && !DrunkRight())
15937 {
15938 if(NO_GRIDLOCK)
15939 {
15940 x = x.getInt();
15941 y = y.getInt();
15942 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15943 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15944 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15945 {
15946 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15947 sprite::move((zfix)-1,(zfix)0);
15948 }
15949 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15950 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15951 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15952 {
15953 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15954 sprite::move((zfix)1,(zfix)0);
15955 }
15956 else
15957 {
15958 pushing=push+1;
15959 }
15960 }
15961 else pushing=push+1;
15962
15963 if(charging==0 && spins==0)
15964 {
15965 dir=down;
15966 }
15967
15968 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15969 {
15970 herostep();
15971 }
15972
15973 return;
15974 }
15975 else goto LEFTRIGHT_NEWMOVE;
15976 }
15977
15978 return;
15979 }
15980
15981 LEFTRIGHT_NEWMOVE:
15982 temp_x = x;
15983 temp_y = y;
15984 temp_step = hero_newstep;
15985 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15986 {
15987 return;
15988 }
15989
15990 if(DrunkLeft())
15991 {
15992 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15993 {
15994 if(dir!=left && dir!=right)
15995 {
15996 if(yoff>2&&yoff<6)
15997 {
15998 move(dir);
15999 }
16000 else if(yoff>=6)
16001 {
16002 move(down);
16003 }
16004 else if(yoff>=1)
16005 {
16006 move(up);
16007 }
16008 }
16009 else
16010 {
16011 if(yoff>=4)
16012 {
16013 move(down);
16014 }
16015 else if(yoff<4)
16016 {
16017 move(up);
16018 }
16019 }
16020 }
16021 else
16022 {
16023 do
16024 {
16025 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16026 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16027
16028 if(y.getInt() & 7)
16029 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16030
16031 if(info.isUnwalkable())
16032 {
16033 if(temp_x != int32_t(temp_x))
16034 {
16035 temp_x = floor((double)temp_x);
16036 }
16037 else if(temp_step > 1)
16038 {
16039 if(temp_step != int32_t(temp_step)) //floor
16040 temp_step = floor((double)temp_step);
16041 else --temp_step;
16042 }
16043 else
16044 break;
16045 }
16046 }
16047 while(info.isUnwalkable());
16048
16049 execute(info);
16050
16051 if(!info.isUnwalkable())
16052 {
16053 x = temp_x;
16054 y = temp_y;
16055 hero_newstep = temp_step;
16056 move(left);
16057 return;
16058 }
16059
16060 if(!DrunkUp() && !DrunkDown())
16061 {
16062 if(NO_GRIDLOCK)
16063 {
16064 x = x.getInt();
16065 y = y.getInt();
16066 int32_t v1=bigHitbox?0:8;
16067 int32_t v2=bigHitbox?8:12;
16068
16069 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16070 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16071 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16072 {
16073 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16074 sprite::move((zfix)0,(zfix)-1);
16075 }
16076 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16077 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16078 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16079 {
16080 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16081 sprite::move((zfix)0,(zfix)1);
16082 }
16083 else
16084 {
16085 pushing=push+1;
16086 }
16087 }
16088 else pushing=push+1;
16089
16090 if(charging==0 && spins==0)
16091 {
16092 dir=left;
16093 }
16094
16095 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16096 {
16097 herostep();
16098 }
16099
16100 return;
16101 }
16102 }
16103
16104 return;
16105 }
16106
16107 if(DrunkRight())
16108 {
16109 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16110 {
16111 if(dir!=left && dir!=right)
16112 {
16113 if(yoff>2&&yoff<6)
16114 {
16115 move(dir);
16116 }
16117 else if(yoff>=6)
16118 {
16119 move(down);
16120 }
16121 else if(yoff>=1)
16122 {
16123 move(up);
16124 }
16125 }
16126 else
16127 {
16128 if(yoff>=4)
16129 {
16130 move(down);
16131 }
16132 else if(yoff<4)
16133 {
16134 move(up);
16135 }
16136 }
16137 }
16138 else
16139 {
16140 do
16141 {
16142 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16143 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16144
16145 if(y.getInt() & 7)
16146 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16147
16148 if(info.isUnwalkable())
16149 {
16150 if(temp_x != int32_t(temp_x))
16151 {
16152 temp_x = floor((double)temp_x);
16153 }
16154 else if(temp_step > 1)
16155 {
16156 if(temp_step != int32_t(temp_step)) //floor
16157 temp_step = floor((double)temp_step);
16158 else --temp_step;
16159 }
16160 else
16161 break;
16162 }
16163 }
16164 while(info.isUnwalkable());
16165
16166 execute(info);
16167
16168 if(!info.isUnwalkable())
16169 {
16170 x = temp_x;
16171 y = temp_y;
16172 hero_newstep = temp_step;
16173 move(right);
16174 return;
16175 }
16176
16177 if(!DrunkUp() && !DrunkDown())
16178 {
16179 if(NO_GRIDLOCK)
16180 {
16181 x = x.getInt();
16182 y = y.getInt();
16183 int32_t v1=bigHitbox?0:8;
16184 int32_t v2=bigHitbox?8:12;
16185
16186 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16187 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16188 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16189 {
16190 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16191 sprite::move((zfix)0,(zfix)-1);
16192 }
16193 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16194 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16195 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16196 {
16197 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16198 sprite::move((zfix)0,(zfix)1);
16199 }
16200 else
16201 {
16202 pushing=push+1;
16203 }
16204 }
16205 else pushing=push+1;
16206
16207 if(charging==0 && spins==0)
16208 {
16209 dir=right;
16210 }
16211
16212 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16213 {
16214 herostep();
16215 }
16216
16217 return;
16218 }
16219 }
16220 }
16221 }
16222 else
16223 {
16224 2289548 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16225 1144774 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16226
16227
10/10
✓ Branch 0 taken 849536 times.
✓ Branch 1 taken 295238 times.
✓ Branch 2 taken 96608 times.
✓ Branch 3 taken 752928 times.
✓ Branch 4 taken 67203 times.
✓ Branch 5 taken 29405 times.
✓ Branch 6 taken 518 times.
✓ Branch 7 taken 66685 times.
✓ Branch 8 taken 438 times.
✓ Branch 9 taken 80 times.
1144774 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16228 {
16229 //ONLY process the side-effects of the above walkflag if Hero will actually move
16230 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16231 438 execute(info);
16232 438 move(left);
16233 438 return;
16234 }
16235
16236 2288672 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16237 1144336 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16238
16239
10/10
✓ Branch 0 taken 849098 times.
✓ Branch 1 taken 295238 times.
✓ Branch 2 taken 105604 times.
✓ Branch 3 taken 743494 times.
✓ Branch 4 taken 71357 times.
✓ Branch 5 taken 34247 times.
✓ Branch 6 taken 619 times.
✓ Branch 7 taken 70738 times.
✓ Branch 8 taken 83 times.
✓ Branch 9 taken 536 times.
1144336 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16240 {
16241 536 execute(info);
16242 536 move(right);
16243 536 return;
16244 }
16245
16246 1143800 ladderx = oldladderx;
16247 1143800 laddery = oldladdery;
16248
16249
2/2
✓ Branch 0 taken 121241 times.
✓ Branch 1 taken 1022559 times.
1143800 if(DrunkUp())
16250 {
16251
11/14
✓ Branch 0 taken 3351 times.
✓ Branch 1 taken 117890 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 3155 times.
✓ Branch 5 taken 144 times.
✓ Branch 6 taken 3155 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3155 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3155 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3152 times.
121241 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16252 {
16253
3/4
✓ Branch 0 taken 3119 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3119 times.
3152 if(dir!=up && dir!=down)
16254 {
16255
4/4
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 978 times.
✓ Branch 2 taken 929 times.
✓ Branch 3 taken 1212 times.
3119 if(xoff>2&&xoff<6)
16256 {
16257 1212 move(dir);
16258 1212 }
16259
2/2
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 978 times.
1907 else if(xoff>=6)
16260 {
16261 929 move(right);
16262 929 }
16263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978 times.
978 else if(xoff>=1)
16264 {
16265 978 move(left);
16266 978 }
16267 3119 }
16268 else
16269 {
16270
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if(xoff>=4)
16271 {
16272 10 move(right);
16273 10 }
16274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 else if(xoff<4)
16275 {
16276 23 move(left);
16277 23 }
16278 }
16279 3152 }
16280 else
16281 {
16282
4/6
✓ Branch 0 taken 115728 times.
✓ Branch 1 taken 2361 times.
✓ Branch 2 taken 115728 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 115728 times.
118089 if(action==swimming || IsSideSwim() || action == swimhit)
16283 {
16284 2361 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16285
16286
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2361 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2361 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 2162 times.
✓ Branch 7 taken 199 times.
4665 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16287
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 2108 times.
4412 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16288 2108 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16289 199 info.setUnwalkable(true);
16290 2361 }
16291 else
16292 {
16293 115728 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16294
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 115673 times.
115728 if(x.getInt() & 7)
16295 55 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16296 else
16297 115673 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16298 }
16299
16300 118089 execute(info);
16301
16302
2/2
✓ Branch 0 taken 44171 times.
✓ Branch 1 taken 73918 times.
118089 if(!info.isUnwalkable())
16303 {
16304 73918 move(up);
16305 73918 return;
16306 }
16307
16308
4/4
✓ Branch 0 taken 40909 times.
✓ Branch 1 taken 3262 times.
✓ Branch 2 taken 3878 times.
✓ Branch 3 taken 37031 times.
44171 if(!DrunkLeft() && !DrunkRight())
16309 {
16310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37031 times.
37031 if(NO_GRIDLOCK)
16311 {
16312 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16313 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16314 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16315 {
16316 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16317 sprite::move((zfix)-1,(zfix)0);
16318 }
16319 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16320 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16321 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16322 {
16323 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16324 sprite::move((zfix)1,(zfix)0);
16325 }
16326 else
16327 {
16328 pushing=push+1;
16329 }
16330 }
16331 37031 else pushing=push+1;
16332
16333
4/4
✓ Branch 0 taken 36848 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 36752 times.
✓ Branch 3 taken 96 times.
37031 if(charging==0 && spins==0)
16334 {
16335 36752 dir=up;
16336 36752 }
16337
16338
5/8
✓ Branch 0 taken 36949 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 36949 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36949 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 36949 times.
37031 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16339 {
16340 36949 herostep();
16341 36949 }
16342
16343 37031 return;
16344 }
16345 else
16346 {
16347 7140 goto LEFTRIGHT_OLDMOVE;
16348 }
16349 }
16350
16351 3152 return;
16352 }
16353
16354
2/2
✓ Branch 0 taken 102879 times.
✓ Branch 1 taken 919680 times.
1022559 if(DrunkDown())
16355 {
16356
11/14
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 100079 times.
✓ Branch 2 taken 2579 times.
✓ Branch 3 taken 221 times.
✓ Branch 4 taken 2384 times.
✓ Branch 5 taken 195 times.
✓ Branch 6 taken 2384 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2384 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2384 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 2383 times.
102879 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16357 {
16358
3/4
✓ Branch 0 taken 2383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2382 times.
2383 if(dir!=up && dir!=down)
16359 {
16360
4/4
✓ Branch 0 taken 1715 times.
✓ Branch 1 taken 667 times.
✓ Branch 2 taken 733 times.
✓ Branch 3 taken 982 times.
2382 if(xoff>2&&xoff<6)
16361 {
16362 982 move(dir);
16363 982 }
16364
2/2
✓ Branch 0 taken 733 times.
✓ Branch 1 taken 667 times.
1400 else if(xoff>=6)
16365 {
16366 733 move(right);
16367 733 }
16368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 667 times.
667 else if(xoff>=1)
16369 {
16370 667 move(left);
16371 667 }
16372 2382 }
16373 else
16374 {
16375
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(xoff>=4)
16376 {
16377 1 move(right);
16378 1 }
16379 else if(xoff<4)
16380 {
16381 move(left);
16382 }
16383 }
16384 2383 }
16385 else
16386 {
16387
4/6
✓ Branch 0 taken 97525 times.
✓ Branch 1 taken 2971 times.
✓ Branch 2 taken 97525 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 97525 times.
100496 if(action==swimming || IsSideSwim() || action == swimhit)
16388 {
16389 2971 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16390
16391
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2971 times.
✓ Branch 2 taken 2971 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 2784 times.
✓ Branch 6 taken 2586 times.
✓ Branch 7 taken 385 times.
5755 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16392
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 2399 times.
5183 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16393 2399 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16394 385 info.setUnwalkable(true);
16395 2971 }
16396 else
16397 {
16398 97525 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16399
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 97302 times.
97525 if(x.getInt() & 7)
16400 223 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16401 else
16402 97302 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16403 }
16404
16405 100496 execute(info);
16406
16407
2/2
✓ Branch 0 taken 40775 times.
✓ Branch 1 taken 59721 times.
100496 if(!info.isUnwalkable())
16408 {
16409 59721 move(down);
16410 59721 return;
16411 }
16412
16413
4/4
✓ Branch 0 taken 37929 times.
✓ Branch 1 taken 2846 times.
✓ Branch 2 taken 3122 times.
✓ Branch 3 taken 34807 times.
40775 if(!DrunkLeft() && !DrunkRight())
16414 {
16415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34807 times.
34807 if(NO_GRIDLOCK)
16416 {
16417 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16418 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16419 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16420 {
16421 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16422 sprite::move((zfix)-1,(zfix)0);
16423 }
16424 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16425 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16426 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16427 {
16428 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16429 sprite::move((zfix)1,(zfix)0);
16430 }
16431 else
16432 {
16433 pushing=push+1;
16434 }
16435 }
16436 34807 else pushing=push+1;
16437
16438
2/4
✓ Branch 0 taken 34807 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34807 times.
✗ Branch 3 not taken.
34807 if(charging==0 && spins==0)
16439 {
16440 34807 dir=down;
16441 34807 }
16442
16443
5/8
✓ Branch 0 taken 34581 times.
✓ Branch 1 taken 226 times.
✓ Branch 2 taken 34581 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34581 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 34581 times.
34807 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16444 {
16445 34581 herostep();
16446 34581 }
16447
16448 34807 return;
16449 }
16450 5968 else goto LEFTRIGHT_OLDMOVE;
16451 }
16452
16453 2383 return;
16454 }
16455
16456 LEFTRIGHT_OLDMOVE:
16457
16458
7/8
✓ Branch 0 taken 698437 times.
✓ Branch 1 taken 240841 times.
✓ Branch 2 taken 675719 times.
✓ Branch 3 taken 22718 times.
✓ Branch 4 taken 6868 times.
✓ Branch 5 taken 691569 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6868 times.
939278 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16459 {
16460 6868 return;
16461 }
16462
16463
2/2
✓ Branch 0 taken 128198 times.
✓ Branch 1 taken 804212 times.
932410 if(DrunkLeft())
16464 {
16465
11/14
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 125760 times.
✓ Branch 2 taken 2415 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 2385 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 2385 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2385 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2385 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 2383 times.
128198 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16466 {
16467
3/4
✓ Branch 0 taken 2378 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2378 times.
2383 if(dir!=left && dir!=right)
16468 {
16469
4/4
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 733 times.
✓ Branch 3 taken 959 times.
2378 if(yoff>2&&yoff<6)
16470 {
16471 959 move(dir);
16472 959 }
16473
2/2
✓ Branch 0 taken 733 times.
✓ Branch 1 taken 686 times.
1419 else if(yoff>=6)
16474 {
16475 733 move(down);
16476 733 }
16477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 else if(yoff>=1)
16478 {
16479 686 move(up);
16480 686 }
16481 2378 }
16482 else
16483 {
16484
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(yoff>=4)
16485 {
16486 5 move(down);
16487 5 }
16488 else if(yoff<4)
16489 {
16490 move(up);
16491 }
16492 }
16493 2383 }
16494 else
16495 {
16496 251630 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16497 125815 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16498
16499 125815 execute(info);
16500
16501
2/2
✓ Branch 0 taken 33798 times.
✓ Branch 1 taken 92017 times.
125815 if(!info.isUnwalkable())
16502 {
16503 92017 move(left);
16504 92017 return;
16505 }
16506
16507
4/4
✓ Branch 0 taken 32541 times.
✓ Branch 1 taken 1257 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 31239 times.
33798 if(!DrunkUp() && !DrunkDown())
16508 {
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31239 times.
31239 if(NO_GRIDLOCK)
16510 {
16511 int32_t v1=bigHitbox?0:8;
16512 int32_t v2=bigHitbox?8:12;
16513
16514 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16515 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16516 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16517 {
16518 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16519 sprite::move((zfix)0,(zfix)-1);
16520 }
16521 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16522 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16523 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16524 {
16525 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16526 sprite::move((zfix)0,(zfix)1);
16527 }
16528 else
16529 {
16530 pushing=push+1;
16531 }
16532 }
16533 31239 else pushing=push+1;
16534
16535
3/4
✓ Branch 0 taken 31233 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31233 times.
31239 if(charging==0 && spins==0)
16536 {
16537 31233 dir=left;
16538 31233 }
16539
16540
5/8
✓ Branch 0 taken 30955 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 30955 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30955 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 30955 times.
31239 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16541 {
16542 30955 herostep();
16543 30955 }
16544
16545 31239 return;
16546 }
16547 }
16548
16549 4942 return;
16550 }
16551
16552
2/2
✓ Branch 0 taken 664980 times.
✓ Branch 1 taken 139232 times.
804212 if(DrunkRight())
16553 {
16554
10/14
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 136749 times.
✓ Branch 2 taken 2459 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2420 times.
✓ Branch 5 taken 39 times.
✓ Branch 6 taken 2420 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2420 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2420 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2420 times.
139232 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16555 {
16556
4/4
✓ Branch 0 taken 2417 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2414 times.
2420 if(dir!=left && dir!=right)
16557 {
16558
4/4
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 694 times.
✓ Branch 2 taken 700 times.
✓ Branch 3 taken 1020 times.
2414 if(yoff>2&&yoff<6)
16559 {
16560 1020 move(dir);
16561 1020 }
16562
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 694 times.
1394 else if(yoff>=6)
16563 {
16564 700 move(down);
16565 700 }
16566
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 else if(yoff>=1)
16567 {
16568 694 move(up);
16569 694 }
16570 2414 }
16571 else
16572 {
16573
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if(yoff>=4)
16574 {
16575 1 move(down);
16576 1 }
16577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(yoff<4)
16578 {
16579 5 move(up);
16580 5 }
16581 }
16582 2420 }
16583 else
16584 {
16585 273624 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16586 136812 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16587
16588 136812 execute(info);
16589
16590
2/2
✓ Branch 0 taken 39022 times.
✓ Branch 1 taken 97790 times.
136812 if(!info.isUnwalkable())
16591 {
16592 97790 move(right);
16593 97790 return;
16594 }
16595
16596
4/4
✓ Branch 0 taken 37362 times.
✓ Branch 1 taken 1660 times.
✓ Branch 2 taken 1095 times.
✓ Branch 3 taken 36267 times.
39022 if(!DrunkUp() && !DrunkDown())
16597 {
16598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36267 times.
36267 if(NO_GRIDLOCK)
16599 {
16600 int32_t v1=bigHitbox?0:8;
16601 int32_t v2=bigHitbox?8:12;
16602
16603 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16604 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16605 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16606 {
16607 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16608 sprite::move((zfix)0,(zfix)-1);
16609 }
16610 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16611 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16612 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16613 {
16614 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16615 sprite::move((zfix)0,(zfix)1);
16616 }
16617 else
16618 {
16619 pushing=push+1;
16620 }
16621 }
16622 36267 else pushing=push+1;
16623
16624
2/4
✓ Branch 0 taken 36267 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36267 times.
36267 if(charging==0 && spins==0)
16625 {
16626 36267 dir=right;
16627 36267 }
16628
16629
5/8
✓ Branch 0 taken 36216 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 36216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36216 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 36216 times.
36267 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16630 {
16631 36216 herostep();
16632 36216 }
16633
16634 36267 return;
16635 }
16636 }
16637 5175 }
16638 }
16639 3503003 }
16640
16641 //solid ffc checking should probably be moved to here.
16642 2027274 void HeroClass::move(int32_t d2, int32_t forceRate)
16643 {
16644
4/6
✓ Branch 0 taken 2027037 times.
✓ Branch 1 taken 237 times.
✓ Branch 2 taken 2027037 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2027037 times.
2027274 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16645 237 return;
16646
16647
3/4
✓ Branch 0 taken 1945123 times.
✓ Branch 1 taken 81914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1945123 times.
2027037 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
16648 {
16649 1945123 moveOld(d2);
16650 1945123 return;
16651 }
16652
16653
4/8
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 78938 times.
✓ Branch 2 taken 2976 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2976 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160852 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
16654
5/6
✓ Branch 0 taken 4699 times.
✓ Branch 1 taken 74239 times.
✓ Branch 2 taken 1836 times.
✓ Branch 3 taken 2863 times.
✓ Branch 4 taken 4699 times.
✗ Branch 5 not taken.
78938 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
16655 //!DIMITODO: add QR for slow combos under hero
16656
2/2
✓ Branch 0 taken 163828 times.
✓ Branch 1 taken 81914 times.
245742 for (int32_t i = 0; i <= 1; ++i)
16657 {
16658
2/2
✓ Branch 0 taken 50375 times.
✓ Branch 1 taken 113453 times.
163828 if(tmpscr2[i].valid!=0)
16659 {
16660
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 111011 times.
113453 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
16661 {
16662
2/4
✓ Branch 0 taken 111011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111011 times.
✗ Branch 3 not taken.
111011 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16663 111011 }
16664 else
16665 {
16666
2/4
✓ Branch 0 taken 2442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2442 times.
✗ Branch 3 not taken.
2442 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16667 }
16668 113453 }
16669 163828 }
16670
1/2
✓ Branch 0 taken 81914 times.
✗ Branch 1 not taken.
81914 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16671 81914 bool is_swimming = (action == swimming);
16672 81914 bool fastSwim = (zinit.hero_swim_speed>60);
16673 81914 zfix rate(steprate);
16674 81914 int32_t shieldid = getCurrentActiveShield();
16675
1/2
✓ Branch 0 taken 81914 times.
✗ Branch 1 not taken.
81914 if(shieldid > -1)
16676 {
16677 itemdata const& shield = itemsbuf[shieldid];
16678 if(shield.flags & ITEM_FLAG10) //Change Speed flag
16679 {
16680 zfix perc = shield.misc7;
16681 perc /= 100;
16682 if(perc < 0)
16683 perc = (perc*-1)+1;
16684 rate = (rate * perc) + shield.misc8;
16685 }
16686 }
16687
16688 81914 zfix dx, dy;
16689 81914 zfix movepix(rate / 100);
16690 81914 zfix step(movepix);
16691 81914 zfix step_diag(movepix);
16692 81914 zfix up_step(game->get_sideswim_up() / -100.0);
16693 81914 zfix left_step(game->get_sideswim_side() / -100.0);
16694 81914 zfix right_step(game->get_sideswim_side() / 100.0);
16695 81914 zfix down_step(game->get_sideswim_down() / 100.0);
16696 81914 bool checkladder = false;
16697
16698
2/2
✓ Branch 0 taken 81913 times.
✓ Branch 1 taken 1 times.
81914 if(hero_newstep > movepix) hero_newstep = movepix;
16699
2/2
✓ Branch 0 taken 81913 times.
✓ Branch 1 taken 1 times.
81914 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
16700 //2/3 speed
16701
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 81914 times.
✓ Branch 2 taken 78938 times.
✓ Branch 3 taken 78938 times.
✓ Branch 4 taken 81914 times.
✓ Branch 5 taken 78938 times.
81914 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
16702 {
16703 160852 step = ((step / 3.0) * 2);
16704 160852 step_diag = ((step_diag / 3.0) * 2);
16705 160852 up_step = ((up_step / 3.0) * 2);
16706 160852 left_step = ((left_step / 3.0) * 2);
16707 160852 right_step = ((right_step / 3.0) * 2);
16708 160852 down_step = ((down_step / 3.0) * 2);
16709 160852 }
16710 //1/2 speed
16711
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 78938 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78938 times.
78938 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
16712 {
16713 step /= 2;
16714 step_diag /= 2;
16715 up_step /= 2;
16716 left_step /= 2;
16717 right_step /= 2;
16718 down_step /= 2;
16719 }
16720 //normal speed
16721 else
16722 {
16723 //no modification
16724 }
16725
16726
1/2
✓ Branch 0 taken 81914 times.
✗ Branch 1 not taken.
81914 if(diagonalMovement)
16727 {
16728 //zprint2("Player's X is %d, Y is %d\n", x, y);
16729
6/6
✓ Branch 0 taken 65524 times.
✓ Branch 1 taken 16390 times.
✓ Branch 2 taken 67714 times.
✓ Branch 3 taken 2190 times.
✓ Branch 4 taken 29044 times.
✓ Branch 5 taken 55060 times.
125626 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
16730
4/4
✓ Branch 0 taken 50071 times.
✓ Branch 1 taken 47881 times.
✓ Branch 2 taken 4169 times.
✓ Branch 3 taken 45902 times.
2190 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
16731 {
16732
2/4
✓ Branch 0 taken 17696 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17696 times.
127816 if(hero_newstep > 0 && hero_newstep_diag > 0)
16733 {
16734 17696 step = STEP_DIAGONAL(step);
16735 17696 step_diag = STEP_DIAGONAL(step_diag);
16736 17696 up_step = STEP_DIAGONAL(up_step);
16737 17696 left_step = STEP_DIAGONAL(left_step);
16738 17696 right_step = STEP_DIAGONAL(right_step);
16739 17696 down_step = STEP_DIAGONAL(down_step);
16740 17696 }
16741 17696 }
16742
2/2
✓ Branch 0 taken 56970 times.
✓ Branch 1 taken 6628 times.
63598 if(hero_newstep < step) step = hero_newstep; //handle collision
16743
2/2
✓ Branch 0 taken 60820 times.
✓ Branch 1 taken 2778 times.
63598 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
16744
5/5
✓ Branch 0 taken 18316 times.
✓ Branch 1 taken 16390 times.
✓ Branch 2 taken 16580 times.
✓ Branch 3 taken 23631 times.
✓ Branch 4 taken 25313 times.
63598 switch(d2)
16745 {
16746 case up:
16747
3/3
✓ Branch 0 taken 12949 times.
✓ Branch 1 taken 1674 times.
✓ Branch 2 taken 1767 times.
16390 switch(shiftdir)
16748 {
16749 case left:
16750 1674 dx = -step_diag;
16751
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if (IsSideSwim()) dx = left_step;
16752 1674 break;
16753 case right:
16754 1767 dx = step_diag;
16755
1/2
✓ Branch 0 taken 1767 times.
✗ Branch 1 not taken.
1767 if (IsSideSwim()) dx = right_step;
16756 1767 break;
16757 }
16758
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 13876 times.
16390 if(walkable)
16759 {
16760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13876 times.
13876 if (!IsSideSwim()) dy = -step;
16761
1/2
✓ Branch 0 taken 13876 times.
✗ Branch 1 not taken.
13876 if (IsSideSwim())
16762 {
16763 dy = up_step;
16764 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16765 }
16766 13876 }
16767 16390 break;
16768 case down:
16769
3/3
✓ Branch 0 taken 11809 times.
✓ Branch 1 taken 2252 times.
✓ Branch 2 taken 2519 times.
16580 switch(shiftdir)
16770 {
16771 case left:
16772 2252 dx = -step_diag;
16773
1/2
✓ Branch 0 taken 2252 times.
✗ Branch 1 not taken.
2252 if (IsSideSwim()) dx = left_step;
16774 2252 break;
16775 case right:
16776 2519 dx = step_diag;
16777
1/2
✓ Branch 0 taken 2519 times.
✗ Branch 1 not taken.
2519 if (IsSideSwim()) dx = right_step;
16778 2519 break;
16779 }
16780
2/2
✓ Branch 0 taken 2469 times.
✓ Branch 1 taken 14111 times.
16580 if(walkable)
16781 {
16782 14111 dy = step;
16783
1/2
✓ Branch 0 taken 14111 times.
✗ Branch 1 not taken.
14111 if (IsSideSwim()) dy = down_step;
16784 14111 }
16785 16580 break;
16786 case left:
16787
3/3
✓ Branch 0 taken 18831 times.
✓ Branch 1 taken 2728 times.
✓ Branch 2 taken 2072 times.
23631 switch(shiftdir)
16788 {
16789 case up:
16790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2728 times.
2728 if (!IsSideSwim()) dy = -step_diag;
16791
1/2
✓ Branch 0 taken 2728 times.
✗ Branch 1 not taken.
2728 if (IsSideSwim())
16792 {
16793 dy = up_step;
16794 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16795 }
16796 2728 break;
16797 case down:
16798 2072 dy = step_diag;
16799
1/2
✓ Branch 0 taken 2072 times.
✗ Branch 1 not taken.
2072 if (IsSideSwim()) dy = down_step;
16800 2072 break;
16801 }
16802
2/2
✓ Branch 0 taken 2379 times.
✓ Branch 1 taken 21252 times.
23631 if(walkable)
16803 {
16804 21252 dx = -step;
16805
1/2
✓ Branch 0 taken 21252 times.
✗ Branch 1 not taken.
21252 if (IsSideSwim()) dx = left_step;
16806 21252 }
16807 23631 break;
16808 case right:
16809
3/3
✓ Branch 0 taken 20629 times.
✓ Branch 1 taken 2504 times.
✓ Branch 2 taken 2180 times.
25313 switch(shiftdir)
16810 {
16811 case up:
16812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504 times.
2504 if (!IsSideSwim()) dy = -step_diag;
16813
1/2
✓ Branch 0 taken 2504 times.
✗ Branch 1 not taken.
2504 if (IsSideSwim())
16814 {
16815 dy = up_step;
16816 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16817 }
16818 2504 break;
16819 case down:
16820 2180 dy = step_diag;
16821
1/2
✓ Branch 0 taken 2180 times.
✗ Branch 1 not taken.
2180 if (IsSideSwim()) dy = down_step;
16822 2180 break;
16823 }
16824
2/2
✓ Branch 0 taken 2470 times.
✓ Branch 1 taken 22843 times.
25313 if(walkable)
16825 {
16826 22843 dx = step;
16827
1/2
✓ Branch 0 taken 22843 times.
✗ Branch 1 not taken.
22843 if (IsSideSwim()) dx = right_step;
16828 22843 }
16829 25313 break;
16830 };
16831 100230 }
16832 else
16833 {
16834 if(hero_newstep < step) step = hero_newstep; //handle collision
16835 switch(d2)
16836 {
16837 case up:
16838 dy -= step;
16839 if (IsSideSwim()) dy = up_step;
16840 break;
16841 case down:
16842 dy += step;
16843 if (IsSideSwim()) dy = down_step;
16844 break;
16845 case left:
16846 dx -= step;
16847 if (IsSideSwim()) dx = left_step;
16848 break;
16849 case right:
16850 dx += step;
16851 if (IsSideSwim()) dx = right_step;
16852 break;
16853 };
16854 }
16855 100230 hero_newstep = movepix;
16856 100230 hero_newstep_diag = movepix;
16857
16858
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 100230 times.
✓ Branch 2 taken 81914 times.
✓ Branch 3 taken 18316 times.
✓ Branch 4 taken 81914 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 81914 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 81914 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
100230 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
16859 {
16860 81914 dir=d2;
16861 81914 }
16862
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 18316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
18316 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
16863 {
16864 dir = shiftdir;
16865 }
16866
1/2
✓ Branch 0 taken 100230 times.
✗ Branch 1 not taken.
100230 if(forceRate > -1)
16867 {
16868 checkladder = false;
16869 switch(dir)
16870 {
16871 case right:
16872 case r_up:
16873 case r_down:
16874 dx = zfix(forceRate) / 100;
16875 break;
16876 case left:
16877 case l_up:
16878 case l_down:
16879 dx = zfix(-forceRate) / 100;
16880 break;
16881 default:
16882 dx = 0;
16883 }
16884 switch(dir)
16885 {
16886 case down:
16887 case r_down:
16888 case l_down:
16889 dy = zfix(forceRate) / 100;
16890 break;
16891 case up:
16892 case r_up:
16893 case l_up:
16894 dy = zfix(-forceRate) / 100;
16895 break;
16896 default:
16897 dy = 0;
16898 }
16899 }
16900
4/4
✓ Branch 0 taken 29607 times.
✓ Branch 1 taken 70623 times.
✓ Branch 2 taken 23101 times.
✓ Branch 3 taken 6506 times.
100230 if(dx == 0 && dy == 0) return;
16901
5/8
✓ Branch 0 taken 75408 times.
✓ Branch 1 taken 18316 times.
✓ Branch 2 taken 75408 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75408 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 75408 times.
93724 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16902 {
16903 75408 herostep();
16904
16905 //ack... don't walk if in midair! -DD
16906
10/14
✓ Branch 0 taken 75408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75408 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75408 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 75408 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4274 times.
✓ Branch 9 taken 71134 times.
✓ Branch 10 taken 1621 times.
✓ Branch 11 taken 2653 times.
✓ Branch 12 taken 179 times.
✓ Branch 13 taken 1442 times.
75408 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
16907 {
16908 73966 action=walking; FFCore.setHeroAction(walking);
16909 73966 }
16910
16911
2/2
✓ Branch 0 taken 71548 times.
✓ Branch 1 taken 3860 times.
75408 if(++hero_count > (16*hero_animation_speed))
16912 3860 hero_count=0;
16913 75408 }
16914
1/2
✓ Branch 0 taken 18316 times.
✗ Branch 1 not taken.
18316 else if(!(frame & 1))
16915 {
16916 herostep();
16917 }
16918
16919
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93724 times.
✓ Branch 2 taken 18316 times.
✓ Branch 3 taken 18316 times.
93724 if(charging==0 || attack!=wHammer)
16920 {
16921 112040 sprite::move(dx, dy);
16922 112040 WalkflagInfo info;
16923 112040 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
16924 112040 execute(info);
16925
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 75408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 75408 times.
✗ Branch 7 not taken.
112040 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
16926 {
16927 if (game->get_sideswim_jump() != 0)
16928 {
16929 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
16930 sfx(WAV_ZN1SPLASH,(int32_t)x);
16931 hopclk = 0;
16932 if (charging || spins) action = attacking;
16933 else action = none;
16934 }
16935 else
16936 {
16937 sprite::move(zfix(0), zfix(-1*dy));
16938 }
16939 }
16940 75408 }
16941 2045590 }
16942
16943 1945123 void HeroClass::moveOld(int32_t d2)
16944 {
16945 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
16946 static bool totalskip = false;
16947
16948
3/6
✓ Branch 0 taken 1945123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1945123 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1945123 times.
1945123 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16949 return;
16950
16951 1945123 int32_t dx=0,dy=0;
16952 1945123 int32_t xstep=lsteps[x.getInt()&7];
16953 1945123 int32_t ystep=lsteps[y.getInt()&7];
16954 1945123 int32_t z3skip=0;
16955 1945123 int32_t z3diagskip=0;
16956
3/6
✓ Branch 0 taken 54733 times.
✓ Branch 1 taken 1890390 times.
✓ Branch 2 taken 54733 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3835513 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
16957
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 1741037 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
1890390 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
16958
2/2
✓ Branch 0 taken 1944537 times.
✓ Branch 1 taken 586 times.
1945123 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16959 1945123 bool is_swimming = (action == swimming);
16960
16961 //slow walk combo, or charging, moves at 2/3 speed
16962 if(
16963
4/4
✓ Branch 0 taken 1926851 times.
✓ Branch 1 taken 18272 times.
✓ Branch 2 taken 55096 times.
✓ Branch 3 taken 1871755 times.
1963395 (!is_swimming && (slowcharging ^ slowcombo))||
16964
2/2
✓ Branch 0 taken 18272 times.
✓ Branch 1 taken 1871755 times.
1890027 (is_swimming && (zinit.hero_swim_speed>60))
16965 )
16966 {
16967 73368 totalskip = false;
16968
16969
2/2
✓ Branch 0 taken 4647 times.
✓ Branch 1 taken 68721 times.
73368 if(diagonalMovement)
16970 {
16971 4647 skipstep=(skipstep+1)%6;
16972
16973
2/2
✓ Branch 0 taken 2359 times.
✓ Branch 1 taken 2288 times.
4647 if(skipstep%2==0) z3skip=1;
16974 2359 else z3skip=0;
16975
16976
2/2
✓ Branch 0 taken 3136 times.
✓ Branch 1 taken 1511 times.
4647 if(skipstep%3==0) z3diagskip=1;
16977 3136 else z3diagskip=0;
16978 4647 }
16979 else
16980 {
16981
2/2
✓ Branch 0 taken 47092 times.
✓ Branch 1 taken 21629 times.
68721 if(d2<left)
16982 {
16983
2/2
✓ Branch 0 taken 28378 times.
✓ Branch 1 taken 18714 times.
47092 if(ystep>1)
16984 {
16985 18714 skipstep^=1;
16986 18714 ystep=skipstep;
16987 18714 }
16988 47092 }
16989 else
16990 {
16991
2/2
✓ Branch 0 taken 13135 times.
✓ Branch 1 taken 8494 times.
21629 if(xstep>1)
16992 {
16993 8494 skipstep^=1;
16994 8494 xstep=skipstep;
16995 8494 }
16996 }
16997 }
16998 73368 }
16999 // else if(is_swimming || (slowcharging && slowcombo))
17000 else if(
17001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1871755 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1871866 (is_swimming && (zinit.hero_swim_speed<60))||
17002
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 1871644 times.
1871755 (slowcharging && slowcombo)
17003 )
17004 {
17005 //swimming, or charging on a slow combo, moves at 1/2 speed
17006 111 totalskip = !totalskip;
17007
17008
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
17009 {
17010 skipstep=0;
17011 }
17012 111 }
17013 else
17014 {
17015 1871644 totalskip = false;
17016
17017
2/2
✓ Branch 0 taken 1662083 times.
✓ Branch 1 taken 209561 times.
1871644 if(diagonalMovement)
17018 {
17019 209561 skipstep=0;
17020 209561 }
17021 }
17022
17023
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1945067 times.
1945123 if(!totalskip)
17024 {
17025
2/2
✓ Branch 0 taken 214208 times.
✓ Branch 1 taken 1730859 times.
1945067 if(diagonalMovement)
17026 {
17027
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 31610 times.
✓ Branch 2 taken 20287 times.
✓ Branch 3 taken 86909 times.
✓ Branch 4 taken 75402 times.
214208 switch(d2)
17028 {
17029 case up:
17030
2/2
✓ Branch 0 taken 2877 times.
✓ Branch 1 taken 28733 times.
31610 if(shiftdir==left)
17031 {
17032
2/2
✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 1154 times.
2877 if(walkable)
17033 {
17034 1723 dy-=1-z3diagskip;
17035 1723 dx-=1-z3diagskip;
17036 1723 z3step=2;
17037 1723 }
17038 else
17039 {
17040 1154 dx-=1-z3diagskip;
17041 1154 z3step=2;
17042 }
17043 2877 }
17044
2/2
✓ Branch 0 taken 3523 times.
✓ Branch 1 taken 25210 times.
28733 else if(shiftdir==right)
17045 {
17046
2/2
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 1600 times.
3523 if(walkable)
17047 {
17048 1923 dy-=1-z3diagskip;
17049 1923 dx+=1-z3diagskip;
17050 1923 z3step=2;
17051 1923 }
17052 else
17053 {
17054 1600 dx+=1-z3diagskip;
17055 1600 z3step=2;
17056 }
17057 3523 }
17058 else
17059 {
17060
2/2
✓ Branch 0 taken 14499 times.
✓ Branch 1 taken 10711 times.
25210 if(walkable)
17061 {
17062 10711 dy-=z3step-z3skip;
17063 10711 z3step=(z3step%2)+1;
17064 10711 }
17065 }
17066
17067 31610 break;
17068
17069 case down:
17070
2/2
✓ Branch 0 taken 2497 times.
✓ Branch 1 taken 17790 times.
20287 if(shiftdir==left)
17071 {
17072
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 1246 times.
2497 if(walkable)
17073 {
17074 1251 dy+=1-z3diagskip;
17075 1251 dx-=1-z3diagskip;
17076 1251 z3step=2;
17077 1251 }
17078 else
17079 {
17080 1246 dx-=1-z3diagskip;
17081 1246 z3step=2;
17082 }
17083 2497 }
17084
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 15070 times.
17790 else if(shiftdir==right)
17085 {
17086
2/2
✓ Branch 0 taken 1803 times.
✓ Branch 1 taken 917 times.
2720 if(walkable)
17087 {
17088 1803 dy+=1-z3diagskip;
17089 1803 dx+=1-z3diagskip;
17090 1803 z3step=2;
17091 1803 }
17092 else
17093 {
17094 917 dx+=1-z3diagskip;
17095 917 z3step=2;
17096 }
17097 2720 }
17098 else
17099 {
17100
2/2
✓ Branch 0 taken 7783 times.
✓ Branch 1 taken 7287 times.
15070 if(walkable)
17101 {
17102 7287 dy+=z3step-z3skip;
17103 7287 z3step=(z3step%2)+1;
17104 7287 }
17105 }
17106
17107 20287 break;
17108
17109 case right:
17110
2/2
✓ Branch 0 taken 83578 times.
✓ Branch 1 taken 3331 times.
86909 if(shiftdir==up)
17111 {
17112
2/2
✓ Branch 0 taken 3149 times.
✓ Branch 1 taken 182 times.
3331 if(walkable)
17113 {
17114 3149 dy-=1-z3diagskip;
17115 3149 dx+=1-z3diagskip;
17116 3149 z3step=2;
17117 3149 }
17118 else
17119 {
17120 182 dy-=1-z3diagskip;
17121 182 z3step=2;
17122 }
17123 3331 }
17124
2/2
✓ Branch 0 taken 2324 times.
✓ Branch 1 taken 81254 times.
83578 else if(shiftdir==down)
17125 {
17126
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 158 times.
2324 if(walkable)
17127 {
17128 2166 dy+=1-z3diagskip;
17129 2166 dx+=1-z3diagskip;
17130 2166 z3step=2;
17131 2166 }
17132 else
17133 {
17134 158 dy+=1-z3diagskip;
17135 158 z3step=2;
17136 }
17137 2324 }
17138 else
17139 {
17140
2/2
✓ Branch 0 taken 8415 times.
✓ Branch 1 taken 72839 times.
81254 if(walkable)
17141 {
17142 72839 dx+=z3step-z3skip;
17143 72839 z3step=(z3step%2)+1;
17144 72839 }
17145 }
17146
17147 86909 break;
17148
17149 case left:
17150
2/2
✓ Branch 0 taken 72905 times.
✓ Branch 1 taken 2497 times.
75402 if(shiftdir==up)
17151 {
17152
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 154 times.
2497 if(walkable)
17153 {
17154 2343 dy-=1-z3diagskip;
17155 2343 dx-=1-z3diagskip;
17156 2343 z3step=2;
17157 2343 }
17158 else
17159 {
17160 154 dy-=1-z3diagskip;
17161 154 z3step=2;
17162 }
17163 2497 }
17164
2/2
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 70682 times.
72905 else if(shiftdir==down)
17165 {
17166
2/2
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 182 times.
2223 if(walkable)
17167 {
17168 2041 dy+=1-z3diagskip;
17169 2041 dx-=1-z3diagskip;
17170 2041 z3step=2;
17171 2041 }
17172 else
17173 {
17174 182 dy+=1-z3diagskip;
17175 182 z3step=2;
17176 }
17177 2223 }
17178 else
17179 {
17180
2/2
✓ Branch 0 taken 6674 times.
✓ Branch 1 taken 64008 times.
70682 if(walkable)
17181 {
17182 64008 dx-=z3step-z3skip;
17183 64008 z3step=(z3step%2)+1;
17184 64008 }
17185 }
17186
17187 75402 break;
17188 }
17189 214208 }
17190 else
17191 {
17192
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 414454 times.
✓ Branch 2 taken 327386 times.
✓ Branch 3 taken 477112 times.
✓ Branch 4 taken 511907 times.
1730859 switch(d2)
17193 {
17194 case up:
17195
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 414146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
414454 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
17196
17197 414454 break;
17198
17199 case down:
17200
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 327332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
327386 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
17201
17202 327386 break;
17203
17204 case left:
17205 477112 dx-=xstep;
17206 477112 break;
17207
17208 case right:
17209 511907 dx+=xstep;
17210 511907 break;
17211 }
17212 }
17213 1945067 }
17214
17215
8/16
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 1944537 times.
✓ Branch 2 taken 1944258 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 1944062 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 1944062 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1944062 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1945123 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
17216 {
17217 1944062 dir=d2;
17218 1944062 }
17219
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1061 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1061 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
17220 {
17221 dir = shiftdir;
17222 }
17223
17224
3/4
✓ Branch 0 taken 1926851 times.
✓ Branch 1 taken 18272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1926851 times.
1945123 if(action != swimming && !IsSideSwim())
17225 {
17226 1926851 herostep();
17227
17228 //ack... don't walk if in midair! -DD
17229
12/14
✓ Branch 0 taken 1926265 times.
✓ Branch 1 taken 586 times.
✓ Branch 2 taken 1925986 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 1925826 times.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 1925826 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 1776473 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
1926851 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
17230 {
17231 1844071 action=walking; FFCore.setHeroAction(walking);
17232 1844071 }
17233
17234
2/2
✓ Branch 0 taken 1824651 times.
✓ Branch 1 taken 102200 times.
1926851 if(++hero_count > (16*hero_animation_speed))
17235 102200 hero_count=0;
17236 1926851 }
17237
2/2
✓ Branch 0 taken 9128 times.
✓ Branch 1 taken 9144 times.
18272 else if(!(frame & 1))
17238 {
17239 9144 herostep();
17240 9144 }
17241
17242
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 1944537 times.
✓ Branch 2 taken 586 times.
✗ Branch 3 not taken.
1945123 if(charging==0 || attack!=wHammer)
17243 {
17244 1945123 sprite::move((zfix)dx,(zfix)dy);
17245 1945123 }
17246 1945123 }
17247
17248 8406075 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
17249 {
17250 8406075 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
17251 }
17252 8406075 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
17253 {
17254 8406075 WalkflagInfo ret;
17255
17256 8406075 wx = vbound(wx, -1, 256);
17257 8406075 wy = vbound(wy, -1, 176);
17258
17259
7/8
✓ Branch 0 taken 8377814 times.
✓ Branch 1 taken 28261 times.
✓ Branch 2 taken 8356278 times.
✓ Branch 3 taken 21536 times.
✓ Branch 4 taken 8356278 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1171 times.
✓ Branch 7 taken 8355107 times.
8406075 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
17260 {
17261 50968 ret.setUnwalkable(false);
17262 50968 return ret;
17263 }
17264
17265
2/2
✓ Branch 0 taken 41482 times.
✓ Branch 1 taken 8313625 times.
8355107 if(toogam)
17266 {
17267 41482 ret.setUnwalkable(false);
17268 41482 return ret;
17269 }
17270
17271
4/4
✓ Branch 0 taken 144389 times.
✓ Branch 1 taken 8169236 times.
✓ Branch 2 taken 144102 times.
✓ Branch 3 taken 287 times.
8313625 if(blockpath && wy<(bigHitbox?80:88))
17272 {
17273 287 ret.setUnwalkable(true);
17274 287 return ret;
17275 }
17276
17277
4/4
✓ Branch 0 taken 55906 times.
✓ Branch 1 taken 8257432 times.
✓ Branch 2 taken 42519 times.
✓ Branch 3 taken 13387 times.
8313338 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
17278 {
17279 13387 ret.setUnwalkable(true);
17280 13387 return ret;
17281 }
17282
17283
2/2
✓ Branch 0 taken 6265 times.
✓ Branch 1 taken 8293686 times.
8299951 if (collide_object(wx, wy,1, 1))
17284 {
17285 6265 ret.setUnwalkable(true);
17286 6265 return ret;
17287 }
17288
17289
14/20
✓ Branch 0 taken 5409267 times.
✓ Branch 1 taken 2884419 times.
✓ Branch 2 taken 5182934 times.
✓ Branch 3 taken 226333 times.
✓ Branch 4 taken 4983269 times.
✓ Branch 5 taken 199665 times.
✓ Branch 6 taken 199665 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 199665 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 129143 times.
✓ Branch 13 taken 70522 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 70522 times.
✓ Branch 16 taken 70522 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6250 times.
✓ Branch 19 taken 8287436 times.
8438003 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17290
2/2
✓ Branch 0 taken 15174 times.
✓ Branch 1 taken 55348 times.
199665 && !get_bit(quest_rules,qr_FREEFORM))
17291 {
17292 6250 ret.setUnwalkable(true);
17293 6250 return ret;
17294 }
17295
17296
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8287436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8287436 times.
8287436 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
17297
17298
6/6
✓ Branch 0 taken 5403017 times.
✓ Branch 1 taken 2884419 times.
✓ Branch 2 taken 5176684 times.
✓ Branch 3 taken 226333 times.
✓ Branch 4 taken 2438471 times.
✓ Branch 5 taken 2738213 times.
8287436 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17299 {
17300
2/4
✓ Branch 0 taken 2738213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2738213 times.
2738213 if((diagonalMovement||NO_GRIDLOCK))
17301 {
17302 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
17303
17304 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
17305 }
17306 2738213 }
17307 //All problems related to exiting water are probably here. -Z
17308
3/4
✓ Branch 0 taken 8175142 times.
✓ Branch 1 taken 112294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8175142 times.
8287436 if(action==swimming || IsSideSwim())
17309 {
17310
2/2
✓ Branch 0 taken 104294 times.
✓ Branch 1 taken 8000 times.
112294 if(!wf)
17311 {
17312 8000 bool isthissolid = false;
17313
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8000 times.
✓ Branch 4 taken 4204 times.
✓ Branch 5 taken 3796 times.
12204 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17314
4/6
✓ Branch 0 taken 3796 times.
✓ Branch 1 taken 4204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4204 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4204 times.
8000 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17315
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4204 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4204 times.
4204 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17316
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4204 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4204 times.
8000 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
17317 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17318
17319
17320
5/6
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6945 times.
✓ Branch 4 taken 1747 times.
✓ Branch 5 taken 9747 times.
9055 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
17321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
17322 {
17323 //Check for out of bounds for swimming
17324 1747 bool changehop = true;
17325
17326
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 1328 times.
✓ Branch 2 taken 1328 times.
✓ Branch 3 taken 909 times.
1747 if((diagonalMovement||NO_GRIDLOCK))
17327 {
17328
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2656 if(wx<0||wy<0)
17329 changehop = false;
17330 else if(wx>248)
17331 changehop = false;
17332 else if(wx>240&&cnt==2)
17333 changehop = false;
17334 else if(wy>168)
17335 changehop = false;
17336 }
17337
3/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 490 times.
✓ Branch 2 taken 909 times.
✗ Branch 3 not taken.
909 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
17338 //This may be where the hang-up for exiting water exists. -Z
17339 // hop out of the water
17340
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 419 times.
909 if(changehop)
17341 419 ret.setHopClk(1);
17342 909 }
17343 else
17344 {
17345
6/6
✓ Branch 0 taken 3441 times.
✓ Branch 1 taken 6306 times.
✓ Branch 2 taken 3345 times.
✓ Branch 3 taken 6402 times.
✓ Branch 4 taken 2262 times.
✓ Branch 5 taken 1083 times.
9747 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
17346 {
17347 //int32_t vx=((int32_t)x+4)&0xFFF8;
17348 //int32_t vy=((int32_t)y+4)&0xFFF8;
17349
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 1059 times.
3345 if(d2==left)
17350 {
17351
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
240 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
17352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
17353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 120 times.
120 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17354
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17355 {
17356 120 ret.setHopDir(d2);
17357 120 ret.setIlswim(true);
17358 120 }
17359 else ret.setIlswim(false);
17360 120 }
17361
2/2
✓ Branch 0 taken 916 times.
✓ Branch 1 taken 143 times.
1059 else if(d2==right)
17362 {
17363
4/4
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 220 times.
✓ Branch 3 taken 696 times.
1136 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
17365
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 220 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 220 times.
220 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17366
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 220 times.
220 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17367 {
17368 220 ret.setHopDir(d2);
17369 220 ret.setIlswim(true);
17370 220 }
17371 696 else ret.setIlswim(false);
17372 916 }
17373
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 25 times.
143 else if(d2==up)
17374 {
17375
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
50 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
17376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
17377
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
25 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17378
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17379 {
17380 25 ret.setHopDir(d2);
17381 25 ret.setIlswim(true);
17382 25 }
17383 else ret.setIlswim(false);
17384 25 }
17385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 else if(d2==down)
17386 {
17387
4/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 90 times.
146 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
17388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
17389
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
28 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
17390
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
28 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
17391 {
17392 28 ret.setHopDir(d2);
17393 28 ret.setIlswim(true);
17394 28 }
17395 90 else ret.setIlswim(false);
17396 118 }
17397 1179 }
17398
17399
2/4
✓ Branch 0 taken 7581 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7581 times.
7581 if(wx<0||wy<0);
17400
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 6561 times.
7581 else if(wx>248);
17401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6561 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6561 else if(wx>240&&cnt==2);
17402
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 6400 times.
6561 else if(wy>168);
17403
3/4
✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6106 times.
6400 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17404 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
17405
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 276 times.
294 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17406 {
17407 18 ret.setUnwalkable(false);
17408 18 return ret;
17409 }
17410 else
17411 {
17412 276 ret.setUnwalkable(true);
17413 276 return ret;
17414 }
17415 }
17416 8196 }
17417 else
17418 {
17419 104294 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17420 104294 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
17421
17422
8/8
✓ Branch 0 taken 99151 times.
✓ Branch 1 taken 5143 times.
✓ Branch 2 taken 96956 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 5143 times.
✓ Branch 5 taken 2195 times.
✓ Branch 6 taken 4523 times.
✓ Branch 7 taken 620 times.
104294 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17423 {
17424 101479 ret.setUnwalkable(false);
17425 101479 return ret;
17426 }
17427 }
17428 11011 }
17429
2/2
✓ Branch 0 taken 130481 times.
✓ Branch 1 taken 8044661 times.
8175142 else if(ladderx+laddery) // ladder is being used
17430 {
17431
7/10
✓ Branch 0 taken 5960 times.
✓ Branch 1 taken 124521 times.
✓ Branch 2 taken 5907 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
130481 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
17432
7/10
✓ Branch 0 taken 5960 times.
✓ Branch 1 taken 124521 times.
✓ Branch 2 taken 5907 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
130481 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
17433
17434
3/4
✓ Branch 0 taken 130382 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130382 times.
130481 if((diagonalMovement||NO_GRIDLOCK))
17435 {
17436
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(ladderdir==up)
17437 {
17438 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17439 {
17440 bool temp = false;
17441
17442 if(!(abs(lx-(ladderx+8))<=8))
17443 temp = true;
17444
17445 if(cnt==2)
17446 if(!(abs((lx+8)-(ladderx+8))<=8))
17447 temp=true;
17448
17449 if(!temp)
17450 {
17451 ret.setUnwalkable(false);
17452 return ret;
17453 }
17454
17455 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17456 {
17457 ret.setUnwalkable(true);
17458 return ret;
17459 }
17460 }
17461 }
17462 else
17463 {
17464
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 48 times.
99 if(abs(lx-(ladderx+8))<=8)
17465 {
17466
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37 times.
48 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17467 {
17468 11 ret.setUnwalkable(false);
17469 11 return ret;
17470 }
17471
17472
4/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
37 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17473 {
17474 13 ret.setUnwalkable(true);
17475 13 return ret;
17476 }
17477
17478
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if((abs(ly-laddery+8)<=8) && d2<=down)
17479 {
17480 ret.setUnwalkable(false);
17481 return ret;
17482 }
17483 24 }
17484 }
17485 75 } // diagonalMovement
17486 else
17487 {
17488
2/2
✓ Branch 0 taken 81915 times.
✓ Branch 1 taken 48467 times.
130382 if((d2&2)==ladderdir) // same direction
17489 {
17490
3/3
✓ Branch 0 taken 4498 times.
✓ Branch 1 taken 73195 times.
✓ Branch 2 taken 4222 times.
81915 switch(d2)
17491 {
17492 case up:
17493
2/2
✓ Branch 0 taken 2866 times.
✓ Branch 1 taken 1356 times.
4222 if(y.getInt()<=laddery)
17494 {
17495
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2866 times.
✓ Branch 4 taken 197 times.
✓ Branch 5 taken 2669 times.
5535 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
17496
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2669 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2669 times.
2669 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
17497 2866 return ret;
17498
17499 }
17500
17501 [[fallthrough]];
17502 case down:
17503
2/2
✓ Branch 0 taken 3151 times.
✓ Branch 1 taken 2703 times.
5854 if((wy&0xF0)==laddery)
17504 {
17505 3151 ret.setUnwalkable(false);
17506 3151 return ret;
17507 }
17508
17509 2703 break;
17510
17511 default:
17512
2/2
✓ Branch 0 taken 29513 times.
✓ Branch 1 taken 43682 times.
73195 if((wx&0xF0)==ladderx)
17513 {
17514 29513 ret.setUnwalkable(false);
17515 29513 return ret;
17516 }
17517 43682 }
17518
17519
2/2
✓ Branch 0 taken 2703 times.
✓ Branch 1 taken 43682 times.
46385 if(d2<=down)
17520 {
17521
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2703 times.
✓ Branch 2 taken 2703 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2609 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2609 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2609 times.
2703 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
17522 2703 return ret;
17523 }
17524
17525
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 43682 times.
✓ Branch 2 taken 43682 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6894 times.
✓ Branch 5 taken 36788 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 36788 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 36788 times.
43682 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
17526 43682 return ret;
17527 }
17528
17529 // different dir
17530
3/8
✓ Branch 0 taken 48038 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48038 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48467 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
17531 {
17532 48038 ret.setUnwalkable(true);
17533 48038 return ret;
17534 }
17535
17536
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
17537 {
17538 20 ret.setUnwalkable(false);
17539 20 return ret;
17540 }
17541 }
17542 484 }
17543
6/6
✓ Branch 0 taken 6870488 times.
✓ Branch 1 taken 1174173 times.
✓ Branch 2 taken 6558775 times.
✓ Branch 3 taken 311713 times.
✓ Branch 4 taken 1304021 times.
✓ Branch 5 taken 5254754 times.
8044661 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17544 {
17545 // see if it's a good spot for the ladder or for swimming
17546
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2789907 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2789907 times.
2789907 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17547
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2789907 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2789907 times.
2789907 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
17548
17549
2/2
✓ Branch 0 taken 2064481 times.
✓ Branch 1 taken 725426 times.
2789907 if(get_bit(quest_rules, qr_DROWN))
17550 {
17551 // Drowning changes the following attributes:
17552 // * Dangerous water is also walkable, so ignore the previous
17553 // definitions of unwalkablex and unwalkablex8.
17554 // * Instead, prevent the ladder from being used in the
17555 // one frame where Hero has landed on water before drowning.
17556 2064481 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17557 2064481 }
17558
17559 // check if he can swim
17560
5/6
✓ Branch 0 taken 762133 times.
✓ Branch 1 taken 2027774 times.
✓ Branch 2 taken 761917 times.
✓ Branch 3 taken 216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 761917 times.
2789907 if(current_item(itype_flippers) && z==0 && fakez==0)
17561 {
17562 761917 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17563 761917 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
17564
2/6
✓ Branch 0 taken 761917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 761917 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
761917 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17565 {
17566 //ladder ignores water combos that are now walkable thanks to flippers -DD
17567
2/2
✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 760811 times.
761917 unwalkablex = unwalkablex && (!wtrx);
17568
2/2
✓ Branch 0 taken 77311 times.
✓ Branch 1 taken 684606 times.
761917 unwalkablex8 = unwalkablex8 && (!wtrx8);
17569
17570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 761917 times.
761917 if(landswim >= 22)
17571 {
17572 ret.setHopClk(2);
17573 ret.setUnwalkable(false);
17574 return ret;
17575 }
17576
8/8
✓ Branch 0 taken 663760 times.
✓ Branch 1 taken 98157 times.
✓ Branch 2 taken 2500 times.
✓ Branch 3 taken 661260 times.
✓ Branch 4 taken 98157 times.
✓ Branch 5 taken 661260 times.
✓ Branch 6 taken 268 times.
✓ Branch 7 taken 97889 times.
761917 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17577 {
17578
3/4
✓ Branch 0 taken 2307 times.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2307 times.
2768 if(!(diagonalMovement||NO_GRIDLOCK))
17579 {
17580 2307 ret.setHopClk(2);
17581
17582
2/4
✓ Branch 0 taken 2307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2307 times.
2307 if(charging || spins>5)
17583 {
17584 //if Hero is charging, he might be facing the wrong direction (we want him to
17585 //hop into the water, not in the facing direction)
17586 ret.setDir(d2);
17587 //moreover Hero can't charge in the water -DD
17588 ret.setChargeAttack();
17589 }
17590
17591 2307 ret.setUnwalkable(false);
17592 2307 return ret;
17593 }
17594
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 336 times.
461 else if(dir==d2)
17595 {
17596 336 ret.setIlswim(true);
17597 336 ladderx = 0;
17598 336 laddery = 0;
17599 336 }
17600 461 }
17601 759610 }
17602 759610 }
17603
17604 // check if he can use the ladder
17605 // "Allow Ladder Anywhere" is toggled by fLADDER
17606
2/2
✓ Branch 0 taken 2105752 times.
✓ Branch 1 taken 681848 times.
2787600 if(can_deploy_ladder())
17607 // laddersetup
17608 {
17609 // Check if there's water to use the ladder over
17610 681848 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
17611 681848 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
17612 681848 int32_t ldrid = current_item_id(itype_ladder);
17613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 681848 times.
681848 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17614
17615
4/4
✓ Branch 0 taken 675547 times.
✓ Branch 1 taken 6301 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 675530 times.
681848 if(wtrx || wtrx8)
17616 {
17617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6318 times.
6318 if(isSideViewHero())
17618 {
17619 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17620 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17621 }
17622 // * walk on half-water using the ladder instead of using flippers.
17623 // * otherwise, walk on ladder(+hookshot) combos.
17624
3/8
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 5931 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6318 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
17625 {
17626
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17627 {
17628 //if Hero could swim on a tile instead of using the ladder,
17629 //refuse to use the ladder to step over that tile. -DD
17630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
17631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
17632 387 }
17633 387 }
17634 6318 }
17635 else
17636 {
17637 // No water; check other things
17638
17639 //Check pits
17640
2/2
✓ Branch 0 taken 674503 times.
✓ Branch 1 taken 1027 times.
675530 if(ladderpits)
17641 {
17642 1027 int32_t pit_cmb = getpitfall(wx,wy);
17643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17644 1027 pit_cmb = getpitfall(x+8,wy);
17645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17646 1027 }
17647
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 674503 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
675530 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17648 {
17649 675530 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
17650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675530 times.
675530 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17651 675530 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
17652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675530 times.
675530 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17653 675530 }
17654 }
17655
17656
2/2
✓ Branch 0 taken 1363696 times.
✓ Branch 1 taken 681848 times.
2045544 for (int32_t i = 0; i <= 1; ++i)
17657 {
17658
2/2
✓ Branch 0 taken 1092716 times.
✓ Branch 1 taken 270980 times.
1363696 if(tmpscr2[i].valid!=0)
17659 {
17660
2/2
✓ Branch 0 taken 268926 times.
✓ Branch 1 taken 2054 times.
270980 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17661 {
17662
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268926 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268926 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268926 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268926 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17664 268926 }
17665 else
17666 {
17667
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2054 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2054 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17669 }
17670 270980 }
17671 1363696 }
17672
2/2
✓ Branch 0 taken 533010 times.
✓ Branch 1 taken 148838 times.
681848 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
17673
17674
3/4
✓ Branch 0 taken 672970 times.
✓ Branch 1 taken 8878 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 672970 times.
681848 if((diagonalMovement||NO_GRIDLOCK))
17675 {
17676
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 7646 times.
8878 if(d2==dir)
17677 {
17678 7646 int32_t c = walkwater ? 0:8;
17679 7646 int32_t b = walkwater ? 8:0;
17680
17681
2/2
✓ Branch 0 taken 6401 times.
✓ Branch 1 taken 1245 times.
7646 if(d2>=left)
17682 {
17683 // If the difference between wy and y is small enough
17684
4/4
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 5129 times.
✓ Branch 2 taken 6400 times.
✓ Branch 3 taken 1 times.
6401 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
17685 {
17686 // Don't activate the ladder if it would be entirely
17687 // over water and Hero has the flippers. This isn't
17688 // a good way to do this, but it's too risky
17689 // to make big changes to this stuff.
17690 1 bool deployLadder=true;
17691 1 int32_t lx=wx&0xF0;
17692
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17693 {
17694 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17695 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17696 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17697 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17698 deployLadder=false;
17699 }
17700
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(deployLadder)
17701 {
17702 1 ladderx = wx&0xF0;
17703 1 laddery = y;
17704 1 ladderdir = left;
17705 1 ladderstart = d2;
17706 1 ret.setUnwalkable(laddery!=y.getInt());
17707 1 return ret;
17708 }
17709 }
17710 6400 }
17711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1245 times.
1245 else if(d2<=down)
17712 {
17713 // If the difference between wx and x is small enough
17714
3/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1245 times.
1245 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
17715 {
17716 ladderx = x;
17717 laddery = wy&0xF0;
17718 ladderdir = up;
17719 ladderstart = d2;
17720 ret.setUnwalkable(ladderx!=x.getInt());
17721 return ret;
17722 }
17723
17724
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 755 times.
1245 if(cnt==2)
17725 {
17726
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 755 times.
755 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17727 {
17728 ladderx = x;
17729 laddery = wy&0xF0;
17730 ladderdir = up;
17731 ladderstart = d2;
17732 ret.setUnwalkable(ladderx!=x.getInt());
17733 return ret;
17734 }
17735 755 }
17736 1245 }
17737 7645 }
17738 8877 }
17739 else
17740 {
17741
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 672970 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 672970 times.
✓ Branch 4 taken 106753 times.
✓ Branch 5 taken 566217 times.
672970 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
17742
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 672970 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 672970 times.
✓ Branch 4 taken 633061 times.
✓ Branch 5 taken 39909 times.
672970 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
17743
17744
2/2
✓ Branch 0 taken 619225 times.
✓ Branch 1 taken 53745 times.
672987 if((d2>=left && wtrx)
17745 // Deploy the ladder vertically even if Hero is only half on water.
17746
8/8
✓ Branch 0 taken 7392 times.
✓ Branch 1 taken 611833 times.
✓ Branch 2 taken 53745 times.
✓ Branch 3 taken 611833 times.
✓ Branch 4 taken 450 times.
✓ Branch 5 taken 53295 times.
✓ Branch 6 taken 17 times.
✓ Branch 7 taken 53728 times.
672970 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
17747 {
17748
4/4
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 6925 times.
7392 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
17749 467 ladderdir = up;
17750 else
17751 6925 ladderdir = left;
17752
17753
2/2
✓ Branch 0 taken 6925 times.
✓ Branch 1 taken 467 times.
7392 if(ladderdir==up)
17754 {
17755 467 ladderx = x.getInt()&0xF8;
17756 467 laddery = wy&0xF0;
17757 467 }
17758 else
17759 {
17760 6925 ladderx = wx&0xF0;
17761 6925 laddery = y.getInt()&0xF8;
17762 }
17763
17764 7392 ret.setUnwalkable(false);
17765 7392 return ret;
17766 }
17767 }
17768 674455 }
17769 2780207 }
17770
17771 8046456 ret.setUnwalkable(wf);
17772 8046456 return ret;
17773 8406565 }
17774
17775 // Only checks for moving blocks. Apparently this is a thing we need.
17776 820753 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
17777 {
17778 820753 HeroClass::WalkflagInfo ret;
17779
2/2
✓ Branch 0 taken 6584 times.
✓ Branch 1 taken 814169 times.
820753 if (!blockmoving) //Without this, weird swimming behaviors happen.
17780 {
17781 814169 ret.setFlags(~1);
17782 814169 ret.setHopDir(-1);
17783 814169 }
17784
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 818117 times.
820753 if(toogam) return ret;
17785
2/2
✓ Branch 0 taken 811533 times.
✓ Branch 1 taken 6584 times.
818117 if (blockmoving)
17786 6584 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
17787
2/2
✓ Branch 0 taken 817785 times.
✓ Branch 1 taken 332 times.
818117 if (collide_object(wx, wy,1, 1))
17788 332 ret.setUnwalkable(true);
17789 818117 return ret;
17790 820753 }
17791
17792 3481315 bool HeroClass::checksoliddamage()
17793 {
17794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3481315 times.
3481315 if(toogam) return false;
17795
17796
2/4
✓ Branch 0 taken 3481315 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3481315 times.
3481315 if(z!=0||fakez!=0) return false;
17797 3481315 int32_t bx = x.getInt();
17798 3481315 int32_t by = y.getInt();
17799 3481315 int32_t initk = 0;
17800
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 835162 times.
✓ Branch 2 taken 666806 times.
✓ Branch 3 taken 960609 times.
✓ Branch 4 taken 1018738 times.
3481315 switch(dir)
17801 {
17802 case up:
17803
17804 835162 by-=bigHitbox ? 4 : -4;
17805
17806
1/2
✓ Branch 0 taken 835162 times.
✗ Branch 1 not taken.
835162 if(by<0)
17807 {
17808 return false;
17809 }
17810 835162 break;
17811
17812 case down:
17813
17814 666806 by+=20;
17815
2/2
✓ Branch 0 taken 4518 times.
✓ Branch 1 taken 662288 times.
666806 if(by>175)
17816 {
17817 4518 return false;
17818 }
17819
17820 662288 break;
17821
17822 case left:
17823 960609 bx-=4;
17824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 960609 times.
960609 if (!bigHitbox)
17825 {
17826 960609 by+=8;
17827 960609 initk = 1;
17828 960609 }
17829
2/2
✓ Branch 0 taken 956293 times.
✓ Branch 1 taken 4316 times.
960609 if(bx<0)
17830 {
17831 4316 return false;
17832 }
17833
17834 956293 break;
17835
17836 case right:
17837
17838 1018738 bx+=20;
17839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018738 times.
1018738 if (!bigHitbox)
17840 {
17841 1018738 by+=8;
17842 1018738 initk = 1;
17843 1018738 }
17844
2/2
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 1012921 times.
1018738 if(bx>255)
17845 {
17846 5817 return false;
17847 }
17848
17849 1012921 break;
17850 }
17851 3466664 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
17852 3466664 int32_t t = cmb.type;
17853
1/2
✓ Branch 0 taken 3466664 times.
✗ Branch 1 not taken.
3466664 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17854 t = cNONE;
17855 3466664 int32_t initbx = bx;
17856 3466664 int32_t initby = by;
17857
17858 // Unlike push blocks, damage combos should be tested on layers 2 and under
17859
2/2
✓ Branch 0 taken 7085658 times.
✓ Branch 1 taken 3466648 times.
10552306 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
17860 {
17861 7085658 bx = initbx;
17862 7085658 by = initby;
17863
2/2
✓ Branch 0 taken 17239617 times.
✓ Branch 1 taken 7085642 times.
24325259 for (int32_t k = initk; k <= 2; k++)
17864 {
17865 17239617 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
17866 17239617 t = cmb.type;
17867
1/2
✓ Branch 0 taken 17239617 times.
✗ Branch 1 not taken.
17239617 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17868 t = cNONE;
17869 // Solid damage combos use pushing>0, hence the code is here.
17870
10/10
✓ Branch 0 taken 289294 times.
✓ Branch 1 taken 16950323 times.
✓ Branch 2 taken 92953 times.
✓ Branch 3 taken 196341 times.
✓ Branch 4 taken 87274 times.
✓ Branch 5 taken 5679 times.
✓ Branch 6 taken 1683 times.
✓ Branch 7 taken 85591 times.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 1665 times.
17239617 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
17871 {
17872
14/18
✓ Branch 0 taken 17223393 times.
✓ Branch 1 taken 8880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8880 times.
✓ Branch 4 taken 8880 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1145 times.
✓ Branch 7 taken 7735 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 992 times.
✓ Branch 10 taken 60 times.
✓ Branch 11 taken 93 times.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
✓ Branch 16 taken 17232213 times.
✓ Branch 17 taken 60 times.
17232273 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
17873 {
17874 // Bite Hero
17875
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
17876 54 }
17877 17232267 }
17878
3/4
✓ Branch 0 taken 819929 times.
✓ Branch 1 taken 16419682 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 758111 times.
17997722 if(isSideViewHero() && // Check for sideview damage combos
17879
3/4
✓ Branch 0 taken 758111 times.
✓ Branch 1 taken 61818 times.
✓ Branch 2 taken 758111 times.
✗ Branch 3 not taken.
819929 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
17880 {
17881
2/2
✓ Branch 0 taken 87637 times.
✓ Branch 1 taken 670474 times.
758111 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
17882 {
17883
4/6
✓ Branch 0 taken 87637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 87619 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
87637 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
17884 {
17885
4/4
✓ Branch 0 taken 87610 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 87614 times.
✓ Branch 3 taken 5 times.
87619 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
17886 {
17887
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
17888 }
17889 87614 }
17890
1/2
✓ Branch 0 taken 87632 times.
✗ Branch 1 not taken.
87632 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
17891 87632 }
17892 else
17893 {
17894 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
17895
1/2
✓ Branch 0 taken 670474 times.
✗ Branch 1 not taken.
670474 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
17896 {
17897
2/2
✓ Branch 0 taken 670469 times.
✓ Branch 1 taken 5 times.
1340948 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
17898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 x+8+(zc_max(tmpscr->csensitive-1,0)),
17899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
17900
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 670474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
670474 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
17901 5 return true;
17902 670469 }
17903 else //2.50.1 and later
17904 {
17905 if(checkdamagecombos(x+4, x+12, y+16, y+24))
17906 return true;
17907 }
17908 }
17909
17910 758101 }
17911
2/2
✓ Branch 0 taken 9204951 times.
✓ Branch 1 taken 8034650 times.
17239601 if (dir < left) bx += (k % 2) ? 7 : 8;
17912 8034650 else by += (k % 2) ? 7 : 8;
17913 17239601 }
17914 7085642 }
17915 3466648 return false;
17916 3481315 }
17917 3625005 void HeroClass::checkpushblock()
17918 {
17919
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3611599 times.
3625005 if(toogam) return;
17920
17921
3/4
✓ Branch 0 taken 3608330 times.
✓ Branch 1 taken 3269 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3608330 times.
3611599 if(z!=0||fakez!=0) return;
17922
17923 // Return early in some cases..
17924 3608330 bool earlyReturn=false;
17925
17926
4/4
✓ Branch 0 taken 3106581 times.
✓ Branch 1 taken 501749 times.
✓ Branch 2 taken 3274618 times.
✓ Branch 3 taken 333712 times.
3608330 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
17927
2/2
✓ Branch 0 taken 1157182 times.
✓ Branch 1 taken 2117436 times.
3274618 if(x.getInt()&15) earlyReturn=true;
17928
17929 // if(y<16) return;
17930
4/4
✓ Branch 0 taken 257631 times.
✓ Branch 1 taken 3350699 times.
✓ Branch 2 taken 130616 times.
✓ Branch 3 taken 127015 times.
3608330 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
17931
17932 3481315 int32_t bx = x.getInt()&0xF0;
17933 3481315 int32_t by = (y.getInt()&0xF0);
17934
17935
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 835162 times.
✓ Branch 2 taken 666806 times.
✓ Branch 3 taken 960609 times.
✓ Branch 4 taken 1018738 times.
3481315 switch(dir)
17936 {
17937 case up:
17938
2/2
✓ Branch 0 taken 24624 times.
✓ Branch 1 taken 810538 times.
835162 if(y<16)
17939 {
17940 24624 earlyReturn=true;
17941 24624 break;
17942 }
17943
17944
3/4
✓ Branch 0 taken 133074 times.
✓ Branch 1 taken 677464 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 133074 times.
810538 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
17945
17946
2/2
✓ Branch 0 taken 464392 times.
✓ Branch 1 taken 346146 times.
810538 if((int32_t)x&8) bx+=16;
17947
17948 810538 break;
17949
17950 case down:
17951
2/2
✓ Branch 0 taken 32884 times.
✓ Branch 1 taken 633922 times.
666806 if(y>128)
17952 {
17953 32884 earlyReturn=true;
17954 32884 break;
17955 }
17956 else
17957 {
17958 633922 by+=16;
17959
17960
2/2
✓ Branch 0 taken 397856 times.
✓ Branch 1 taken 236066 times.
633922 if((int32_t)x&8) bx+=16;
17961 }
17962
17963 633922 break;
17964
17965 case left:
17966
2/2
✓ Branch 0 taken 39017 times.
✓ Branch 1 taken 921592 times.
960609 if(x<32)
17967 {
17968 39017 earlyReturn=true;
17969 39017 break;
17970 }
17971 else
17972 {
17973 921592 bx-=16;
17974
17975
2/2
✓ Branch 0 taken 567768 times.
✓ Branch 1 taken 353824 times.
921592 if(y.getInt()&8)
17976 {
17977 353824 by+=16;
17978 353824 }
17979 }
17980
17981 921592 break;
17982
17983 case right:
17984
2/2
✓ Branch 0 taken 42655 times.
✓ Branch 1 taken 976083 times.
1018738 if(x>208)
17985 {
17986 42655 earlyReturn=true;
17987 42655 break;
17988 }
17989 else
17990 {
17991 976083 bx+=16;
17992
17993
2/2
✓ Branch 0 taken 615678 times.
✓ Branch 1 taken 360405 times.
976083 if(y.getInt()&8)
17994 {
17995 360405 by+=16;
17996 360405 }
17997 }
17998
17999 976083 break;
18000 }
18001
18002
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3481299 times.
3481315 if (checksoliddamage()) return;
18003
18004
2/2
✓ Branch 0 taken 2127919 times.
✓ Branch 1 taken 1353380 times.
3481299 if(earlyReturn)
18005 2127919 return;
18006
18007 1353380 int32_t itemid=current_item_id(itype_bracelet);
18008 1353380 size_t combopos = (by&0xF0)+(bx>>4);
18009
2/2
✓ Branch 0 taken 451786 times.
✓ Branch 1 taken 901594 times.
1353380 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
18010
2/2
✓ Branch 0 taken 901594 times.
✓ Branch 1 taken 451786 times.
1353380 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
18011
2/2
✓ Branch 0 taken 608093 times.
✓ Branch 1 taken 2552704 times.
3160797 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
18012 {
18013
4/4
✓ Branch 0 taken 963749 times.
✓ Branch 1 taken 1588955 times.
✓ Branch 2 taken 213000 times.
✓ Branch 3 taken 750749 times.
2552704 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
18014
4/4
✓ Branch 0 taken 1205262 times.
✓ Branch 1 taken 596693 times.
✓ Branch 2 taken 1198120 times.
✓ Branch 3 taken 7142 times.
1801955 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
18015 1198120 continue;
18016 603835 mapscr* m = FFCore.tempScreens[lyr];
18017 603835 int32_t f = MAPFLAG2(lyr-1,bx,by);
18018 603835 int32_t f2 = MAPCOMBOFLAG2(lyr-1,bx,by);
18019 603835 int32_t t = combobuf[MAPCOMBOL(lyr,bx,by)].type;
18020
2/2
✓ Branch 0 taken 1204 times.
✓ Branch 1 taken 602631 times.
603835 if (lyr == 0) t = combobuf[MAPCOMBO(bx,by)].type;
18021
18022
8/8
✓ Branch 0 taken 566253 times.
✓ Branch 1 taken 37582 times.
✓ Branch 2 taken 563494 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 9148 times.
✓ Branch 5 taken 519523 times.
✓ Branch 6 taken 559710 times.
✓ Branch 7 taken 568858 times.
603835 if((t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) && (pushing<16 || hasMainGuy())) continue;
18023
18024
8/8
✓ Branch 0 taken 568318 times.
✓ Branch 1 taken 540 times.
✓ Branch 2 taken 565950 times.
✓ Branch 3 taken 2368 times.
✓ Branch 4 taken 565645 times.
✓ Branch 5 taken 305 times.
✓ Branch 6 taken 695 times.
✓ Branch 7 taken 569925 times.
572952 if((t==cPUSH_HW || t==cPUSH_HEAVY || t==cPUSH_HEAVY2 || t==cPUSH_HW2)
18025
8/8
✓ Branch 0 taken 881 times.
✓ Branch 1 taken 566526 times.
✓ Branch 2 taken 3694 times.
✓ Branch 3 taken 400 times.
✓ Branch 4 taken 305 times.
✓ Branch 5 taken 3389 times.
✓ Branch 6 taken 295 times.
✓ Branch 7 taken 3399 times.
572257 && (itemid<0 || glove->power<((t==cPUSH_HEAVY2 || t==cPUSH_HW2)?2:1) ||
18026
3/4
✓ Branch 0 taken 3393 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
4094 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
18027
18028 569925 bool doit=false;
18029 569925 bool changeflag=false;
18030 569925 bool changecombo=false;
18031
18032
7/8
✓ Branch 0 taken 568798 times.
✓ Branch 1 taken 1127 times.
✓ Branch 2 taken 568798 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 679 times.
✓ Branch 5 taken 569246 times.
✓ Branch 6 taken 289 times.
✓ Branch 7 taken 567896 times.
1138110 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
18033
3/4
✓ Branch 0 taken 568822 times.
✓ Branch 1 taken 424 times.
✓ Branch 2 taken 568822 times.
✗ Branch 3 not taken.
569246 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
18034
4/4
✓ Branch 0 taken 568841 times.
✓ Branch 1 taken 405 times.
✓ Branch 2 taken 568716 times.
✓ Branch 3 taken 125 times.
569246 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
18035
3/4
✓ Branch 0 taken 568802 times.
✓ Branch 1 taken 444 times.
✓ Branch 2 taken 568802 times.
✗ Branch 3 not taken.
569246 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
18036
3/4
✓ Branch 0 taken 568809 times.
✓ Branch 1 taken 437 times.
✓ Branch 2 taken 568809 times.
✗ Branch 3 not taken.
569246 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
18037
3/4
✓ Branch 0 taken 568739 times.
✓ Branch 1 taken 507 times.
✓ Branch 2 taken 568739 times.
✗ Branch 3 not taken.
569246 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
18038
2/2
✓ Branch 0 taken 568185 times.
✓ Branch 1 taken 47 times.
568232 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
18039 {
18040 1015 changeflag=true;
18041 1015 doit=true;
18042 1015 }
18043
18044
7/8
✓ Branch 0 taken 568891 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 568891 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 568901 times.
✓ Branch 6 taken 568890 times.
✓ Branch 7 taken 1 times.
1137792 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
18045
3/4
✓ Branch 0 taken 568891 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 568891 times.
✗ Branch 3 not taken.
568901 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
18046
3/4
✓ Branch 0 taken 568891 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 568891 times.
✗ Branch 3 not taken.
568901 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
18047
3/4
✓ Branch 0 taken 568891 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 568891 times.
✗ Branch 3 not taken.
568901 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
18048
3/4
✓ Branch 0 taken 568891 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 568891 times.
✗ Branch 3 not taken.
568901 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
18049
3/4
✓ Branch 0 taken 568891 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 568891 times.
✗ Branch 3 not taken.
568901 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
18050
1/2
✓ Branch 0 taken 568881 times.
✗ Branch 1 not taken.
568891 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
18051 {
18052 1 changecombo=true;
18053 1 doit=true;
18054 1 }
18055
18056
2/2
✓ Branch 0 taken 69419 times.
✓ Branch 1 taken 499472 times.
568891 if(get_bit(quest_rules,qr_SOLIDBLK))
18057 {
18058
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15436 times.
✓ Branch 2 taken 13838 times.
✓ Branch 3 taken 18736 times.
✓ Branch 4 taken 21409 times.
69419 switch(dir)
18059 {
18060 case up:
18061
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 15436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15436 times.
✓ Branch 4 taken 8639 times.
✓ Branch 5 taken 6797 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6797 times.
✓ Branch 8 taken 8643 times.
✓ Branch 9 taken 6793 times.
15436 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
18062
18063 15436 break;
18064
18065 case down:
18066
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 13838 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13838 times.
✓ Branch 4 taken 5255 times.
✓ Branch 5 taken 8583 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8583 times.
✓ Branch 8 taken 5259 times.
✓ Branch 9 taken 8579 times.
13838 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
18067
18068 13838 break;
18069
18070 case left:
18071
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 18736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18736 times.
✓ Branch 4 taken 8037 times.
✓ Branch 5 taken 10699 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10699 times.
✓ Branch 8 taken 8043 times.
✓ Branch 9 taken 10693 times.
18736 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
18072
18073 18736 break;
18074
18075 case right:
18076
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 21409 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21409 times.
✓ Branch 4 taken 8314 times.
✓ Branch 5 taken 13095 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13095 times.
✓ Branch 8 taken 8324 times.
✓ Branch 9 taken 13085 times.
21409 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
18077
18078 21409 break;
18079 }
18080 69419 }
18081
18082
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 224106 times.
✓ Branch 2 taken 191289 times.
✓ Branch 3 taken 75733 times.
✓ Branch 4 taken 77763 times.
568891 switch(dir)
18083 {
18084 case up:
18085
3/4
✓ Branch 0 taken 223774 times.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 223774 times.
224106 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
18086
18087 224106 break;
18088
18089 case down:
18090
3/4
✓ Branch 0 taken 190873 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 190873 times.
191289 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
18091
18092 191289 break;
18093
18094 case left:
18095
3/4
✓ Branch 0 taken 75651 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75651 times.
75733 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
18096
18097 75733 break;
18098
18099 case right:
18100
3/4
✓ Branch 0 taken 77739 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77739 times.
77763 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
18101
18102 77763 break;
18103 }
18104
18105
2/2
✓ Branch 0 taken 568415 times.
✓ Branch 1 taken 476 times.
568891 if(doit)
18106 {
18107
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if(limitedpush)
18108 7 ++usecounts[itemid];
18109
18110 // for(int32_t i=0; i<1; i++)
18111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 if(!blockmoving)
18112 {
18113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 if(changeflag)
18114 {
18115 476 m->sflag[combopos]=0;
18116 476 }
18117
18118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 if(mblock2.clk<=0)
18119 {
18120 476 mblock2.blockLayer = lyr;
18121 476 mblock2.push((zfix)bx,(zfix)by,dir,f);
18122
18123
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 475 times.
476 if(get_bit(quest_rules,qr_MORESOUNDS))
18124 1 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
18125 476 }
18126 476 }
18127 476 break;
18128 }
18129 568415 }
18130 3630943 }
18131
18132 159 bool usekey()
18133 {
18134 159 int32_t itemid = current_item_id(itype_magickey);
18135
18136
3/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
159 if(itemid<0 ||
18137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18138 : itemsbuf[itemid].power!=dlevel))
18139 {
18140
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 94 times.
129 if(game->lvlkeys[dlevel]!=0)
18141 {
18142 35 game->lvlkeys[dlevel]--;
18143 //run script for level key item
18144 35 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
18145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2975 times.
2975 for ( int32_t q = 0; q < MAXITEMS; ++q )
18146 {
18147
2/2
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 35 times.
2975 if ( itemsbuf[q].family == itype_lkey )
18148 {
18149 35 key_item = q; break;
18150 }
18151 2940 }
18152
18153
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18154 {
18155 ri = &(itemScriptData[key_item]);
18156 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18157 ri->Clear();
18158 item_doscript[key_item] = 1;
18159 itemscriptInitialised[key_item] = 0;
18160 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18161 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18162 }
18163 35 return true;
18164 }
18165 else
18166 {
18167
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 if(game->get_keys()==0)
18168 {
18169 30 return false;
18170 }
18171 else
18172 {
18173 //run script for key item
18174 64 int32_t key_item = 0; //current_item_id(itype_key); //not possible
18175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
640 for ( int32_t q = 0; q < MAXITEMS; ++q )
18176 {
18177
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 64 times.
640 if ( itemsbuf[q].family == itype_key )
18178 {
18179 64 key_item = q; break;
18180 }
18181 576 }
18182 //zprint2("key_item is: %d\n",key_item);
18183 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
18184
2/8
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
64 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18185 {
18186 ri = &(itemScriptData[key_item]);
18187 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18188 ri->Clear();
18189 item_doscript[key_item] = 1;
18190 itemscriptInitialised[key_item] = 0;
18191 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18192 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18193 }
18194 64 game->change_keys(-1);
18195 }
18196 }
18197 64 }
18198
18199 94 return true;
18200 159 }
18201
18202 bool canUseKey(int32_t num)
18203 {
18204 int32_t itemid = current_item_id(itype_magickey);
18205
18206 if(itemid<0 ||
18207 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18208 : itemsbuf[itemid].power!=dlevel))
18209 {
18210 return game->lvlkeys[dlevel] + game->get_keys() >= num;
18211 }
18212
18213 return true;
18214 }
18215
18216 bool usekey(int32_t num)
18217 {
18218 if(!canUseKey(num)) return false;
18219 for(auto q = 0; q < num; ++q)
18220 {
18221 if(!usekey()) return false; //should never return false here, but, just to be safe....
18222 }
18223 return true;
18224 }
18225
18226
18227 454 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
18228 {
18229 454 int32_t mc = (y&0xF0)+(x>>4);
18230
3/6
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
908 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
18231
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 454 times.
✗ Branch 7 not taken.
454 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
18232
3/6
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
454 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
18233
4/8
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 454 times.
454 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
18234 454 return ret;
18235 }
18236
18237 3610329 void HeroClass::oldchecklockblock()
18238 {
18239
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3596923 times.
3610329 if(toogam) return;
18240
18241 3596923 int32_t bx = x.getInt()&0xF0;
18242 3596923 int32_t bx2 = int32_t(x+8)&0xF0;
18243 3596923 int32_t by = y.getInt()&0xF0;
18244
18245
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 848590 times.
✓ Branch 2 taken 673377 times.
✓ Branch 3 taken 1004904 times.
✓ Branch 4 taken 1070052 times.
3596923 switch(dir)
18246 {
18247 case up:
18248
4/4
✓ Branch 0 taken 136844 times.
✓ Branch 1 taken 711746 times.
✓ Branch 2 taken 2437 times.
✓ Branch 3 taken 134407 times.
848590 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18249
18250 848590 break;
18251
18252 case down:
18253 673377 by+=16;
18254 673377 break;
18255
18256 case left:
18257
2/2
✓ Branch 0 taken 450461 times.
✓ Branch 1 taken 554443 times.
1004904 if((((int32_t)x)&0x0F)<8)
18258 554443 bx-=16;
18259
18260
2/2
✓ Branch 0 taken 618711 times.
✓ Branch 1 taken 386193 times.
1004904 if(y.getInt()&8)
18261 {
18262 386193 by+=16;
18263 386193 }
18264
18265 1004904 bx2=bx;
18266 1004904 break;
18267
18268 case right:
18269 1070052 bx+=16;
18270
18271
2/2
✓ Branch 0 taken 674160 times.
✓ Branch 1 taken 395892 times.
1070052 if(y.getInt()&8)
18272 {
18273 395892 by+=16;
18274 395892 }
18275
18276 1070052 bx2=bx;
18277 1070052 break;
18278 }
18279
18280 3596923 bool found1=false;
18281 3596923 bool found2=false;
18282 3596923 int32_t foundlayer = -1;
18283 3596923 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18284 3596923 newcombo const& cmb = combobuf[cid1];
18285 3596923 newcombo const& cmb2 = combobuf[cid2];
18286 // Layer 0 is overridden by Locked Doors
18287
5/8
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 3596543 times.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 380 times.
3596923 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
18288 {
18289 380 found1=true;
18290 380 foundlayer = 0;
18291 380 }
18292
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3596543 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3596543 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
18293 {
18294 found2=true;
18295 foundlayer = 0;
18296 }
18297
18298
2/2
✓ Branch 0 taken 7193846 times.
✓ Branch 1 taken 3596923 times.
10790769 for (int32_t i = 0; i <= 1; ++i)
18299 {
18300
2/2
✓ Branch 0 taken 5856976 times.
✓ Branch 1 taken 1336870 times.
7193846 if(tmpscr2[i].valid!=0)
18301 {
18302
2/2
✓ Branch 0 taken 1229015 times.
✓ Branch 1 taken 107855 times.
1336870 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18303 {
18304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1229015 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1229015 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18305
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1229015 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1229015 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18306 1229015 }
18307 else
18308 {
18309
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18310
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18311 }
18312 1336870 }
18313 7193846 }
18314
18315
18316 // Layers
18317
3/4
✓ Branch 0 taken 3596543 times.
✓ Branch 1 taken 380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3596543 times.
3596923 if(!(found1 || found2))
18318 {
18319 3596543 foundlayer = -1;
18320
2/2
✓ Branch 0 taken 3596509 times.
✓ Branch 1 taken 7193052 times.
10789561 for(int32_t i=0; i<2; i++)
18321 {
18322 7193052 cid1 = MAPCOMBO2(i, bx, by);
18323 7193052 cid2 = MAPCOMBO2(i, bx2, by);
18324 7193052 newcombo const& cmb = combobuf[cid1];
18325 7193052 newcombo const& cmb2 = combobuf[cid2];
18326
2/2
✓ Branch 0 taken 3596509 times.
✓ Branch 1 taken 3596543 times.
7193052 if (i == 0)
18327 {
18328
2/2
✓ Branch 0 taken 3441681 times.
✓ Branch 1 taken 154862 times.
3596543 if(tmpscr2[1].valid!=0)
18329 {
18330
2/2
✓ Branch 0 taken 110308 times.
✓ Branch 1 taken 44554 times.
154862 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18331 {
18332
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110308 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
18333
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110308 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
18334 110308 }
18335 else
18336 {
18337
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18339 }
18340 154862 }
18341 3596543 }
18342
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 7193018 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
7193052 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18343 {
18344 34 found1=true;
18345 34 foundlayer = i+1;
18346 //zprint("Found layer: %d \n", i);
18347 34 break;
18348 }
18349
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7193018 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7193018 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
18350 {
18351 found2=true;
18352 foundlayer = i+1;
18353 //zprint("Found layer: %d \n", i);
18354 break;
18355 }
18356 7193018 }
18357 3596543 }
18358
18359
4/4
✓ Branch 0 taken 3596509 times.
✓ Branch 1 taken 414 times.
✓ Branch 2 taken 3596887 times.
✓ Branch 3 taken 36 times.
3596923 if(!(found1 || found2) || pushing<8)
18360 {
18361 3596887 return;
18362 }
18363
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
18364
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 25 times.
36 if(!try_locked_combo(cmb3))
18365 25 return;
18366
18367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(cmb.usrflags&cflag16)
18368 {
18369 setxmapflag(1<<cmb.attribytes[5]);
18370 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18371 }
18372 else
18373 {
18374 11 setmapflag(mLOCKBLOCK);
18375 11 remove_lockblocks((currscr>=128)?1:0);
18376 }
18377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( cmb3.usrflags&cflag3 )
18378 {
18379 if ( (cmb3.attribytes[3]) )
18380 sfx(cmb3.attribytes[3]);
18381 }
18382 11 else sfx(WAV_DOOR);
18383 3610329 }
18384
18385 3610329 void HeroClass::oldcheckbosslockblock()
18386 {
18387
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3596923 times.
3610329 if(toogam) return;
18388
18389 3596923 int32_t bx = x.getInt()&0xF0;
18390 3596923 int32_t bx2 = int32_t(x+8)&0xF0;
18391 3596923 int32_t by = y.getInt()&0xF0;
18392
18393
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 848590 times.
✓ Branch 2 taken 673377 times.
✓ Branch 3 taken 1004904 times.
✓ Branch 4 taken 1070052 times.
3596923 switch(dir)
18394 {
18395 case up:
18396
4/4
✓ Branch 0 taken 136844 times.
✓ Branch 1 taken 711746 times.
✓ Branch 2 taken 2437 times.
✓ Branch 3 taken 134407 times.
848590 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18397
18398 848590 break;
18399
18400 case down:
18401 673377 by+=16;
18402 673377 break;
18403
18404 case left:
18405
2/2
✓ Branch 0 taken 450461 times.
✓ Branch 1 taken 554443 times.
1004904 if((((int32_t)x)&0x0F)<8)
18406 554443 bx-=16;
18407
18408
2/2
✓ Branch 0 taken 618711 times.
✓ Branch 1 taken 386193 times.
1004904 if(y.getInt()&8)
18409 {
18410 386193 by+=16;
18411 386193 }
18412
18413 1004904 bx2=bx;
18414 1004904 break;
18415
18416 case right:
18417 1070052 bx+=16;
18418
18419
2/2
✓ Branch 0 taken 674160 times.
✓ Branch 1 taken 395892 times.
1070052 if(y.getInt()&8)
18420 {
18421 395892 by+=16;
18422 395892 }
18423
18424 1070052 bx2=bx;
18425 1070052 break;
18426 }
18427
18428
18429 3596923 bool found1 = false;
18430 3596923 bool found2 = false;
18431 3596923 int32_t foundlayer = -1;
18432 3596923 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18433 3596923 newcombo const& cmb = combobuf[cid1];
18434 3596923 newcombo const& cmb2 = combobuf[cid2];
18435 // Layer 0 is overridden by Locked Doors
18436
5/8
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 3596849 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
3596923 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
18437 {
18438 74 found1 = true;
18439 74 foundlayer = 0;
18440 74 }
18441
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3596849 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3596849 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
18442 {
18443 found2 = true;
18444 foundlayer = 0;
18445 }
18446
18447
2/2
✓ Branch 0 taken 7193846 times.
✓ Branch 1 taken 3596923 times.
10790769 for (int32_t i = 0; i <= 1; ++i)
18448 {
18449
2/2
✓ Branch 0 taken 5856976 times.
✓ Branch 1 taken 1336870 times.
7193846 if (tmpscr2[i].valid != 0)
18450 {
18451
2/2
✓ Branch 0 taken 1229015 times.
✓ Branch 1 taken 107855 times.
1336870 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18452 {
18453
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1229015 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1229015 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1229015 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1229015 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18455 1229015 }
18456 else
18457 {
18458
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18459
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18460 }
18461 1336870 }
18462 7193846 }
18463
18464
18465 // Layers
18466
3/4
✓ Branch 0 taken 3596849 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3596849 times.
3596923 if (!(found1 || found2))
18467 {
18468 3596849 foundlayer = -1;
18469
2/2
✓ Branch 0 taken 3596849 times.
✓ Branch 1 taken 7193698 times.
10790547 for (int32_t i = 0; i < 2; i++)
18470 {
18471 7193698 cid1 = MAPCOMBO2(i, bx, by);
18472 7193698 cid2 = MAPCOMBO2(i, bx2, by);
18473 7193698 newcombo const& cmb = combobuf[cid1];
18474 7193698 newcombo const& cmb2 = combobuf[cid2];
18475
2/2
✓ Branch 0 taken 3596849 times.
✓ Branch 1 taken 3596849 times.
7193698 if (i == 0)
18476 {
18477
2/2
✓ Branch 0 taken 3441895 times.
✓ Branch 1 taken 154954 times.
3596849 if (tmpscr2[1].valid != 0)
18478 {
18479
2/2
✓ Branch 0 taken 110336 times.
✓ Branch 1 taken 44618 times.
154954 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18480 {
18481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110336 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110336 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18483 110336 }
18484 else
18485 {
18486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18488 }
18489 154954 }
18490 3596849 }
18491
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7193698 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7193698 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
18492 {
18493 found1 = true;
18494 foundlayer = i;
18495 break;
18496 }
18497
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7193698 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7193698 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
18498 {
18499 found2 = true;
18500 foundlayer = i;
18501 break;
18502 }
18503 7193698 }
18504 3596849 }
18505
18506
4/4
✓ Branch 0 taken 3596849 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 3596903 times.
✓ Branch 3 taken 20 times.
3596923 if (!(found1 || found2) || pushing < 8)
18507 {
18508 3596903 return;
18509 }
18510
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 int32_t cid = found1 ? cid1 : cid2;
18511
18512
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17 times.
20 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18513
18514
18515 // Run Boss Key Script
18516 3 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 for ( int32_t q = 0; q < MAXITEMS; ++q )
18518 {
18519
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 3 times.
204 if ( itemsbuf[q].family == itype_bosskey )
18520 {
18521 3 key_item = q; break;
18522 }
18523 201 }
18524
2/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18525 {
18526 ri = &(itemScriptData[key_item]);
18527 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18528 ri->Clear();
18529 item_doscript[key_item] = 1;
18530 itemscriptInitialised[key_item] = 0;
18531 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18532 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18533 }
18534
18535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb.usrflags&cflag16)
18536 {
18537 setxmapflag(1<<cmb.attribytes[5]);
18538 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18539 }
18540 else
18541 {
18542 3 setmapflag(mBOSSLOCKBLOCK);
18543 3 remove_bosslockblocks((currscr>=128)?1:0);
18544 }
18545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (combobuf[cid].attribytes[3]) )
18546 3 sfx(combobuf[cid].attribytes[3]);
18547 3610329 }
18548
18549 10441986 void HeroClass::oldcheckchest(int32_t type)
18550 {
18551 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
18552
5/6
✓ Branch 0 taken 10401768 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 10392711 times.
✓ Branch 3 taken 9057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10392711 times.
10441986 if(toogam || z>0 || fakez > 0) return;
18553
2/2
✓ Branch 0 taken 10081146 times.
✓ Branch 1 taken 311565 times.
10392711 if(pushing<8) return;
18554 311565 int32_t bx = x.getInt()&0xF0;
18555 311565 int32_t bx2 = int32_t(x+8)&0xF0;
18556 311565 int32_t by = y.getInt()&0xF0;
18557
18558
3/4
✓ Branch 0 taken 136002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77769 times.
✓ Branch 3 taken 97794 times.
311565 switch(dir)
18559 {
18560 case up:
18561
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 57042 times.
97794 if(isSideViewHero()) return;
18562
18563
3/4
✓ Branch 0 taken 10323 times.
✓ Branch 1 taken 46719 times.
✓ Branch 2 taken 10323 times.
✗ Branch 3 not taken.
57042 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18564
18565 57042 break;
18566
18567 case left:
18568 case right:
18569
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 119829 times.
136002 if(isSideViewHero()) break;
18570 [[fallthrough]];
18571 case down:
18572 197598 return;
18573 }
18574
18575 73215 bool found=false;
18576 73215 bool itemflag=false;
18577
18578
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 73207 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
73215 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
18579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73207 times.
73207 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
18580 {
18581 8 found=true;
18582 8 }
18583
2/2
✓ Branch 0 taken 146430 times.
✓ Branch 1 taken 73215 times.
219645 for (int32_t i = 0; i <= 1; ++i)
18584 {
18585
2/2
✓ Branch 0 taken 111603 times.
✓ Branch 1 taken 34827 times.
146430 if(tmpscr2[i].valid!=0)
18586 {
18587
2/2
✓ Branch 0 taken 33966 times.
✓ Branch 1 taken 861 times.
34827 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18588 {
18589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33966 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33966 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33966 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33966 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18591 33966 }
18592 else
18593 {
18594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18595
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18596 }
18597 34827 }
18598 146430 }
18599
18600
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 73207 times.
73215 if(!found)
18601 {
18602
2/2
✓ Branch 0 taken 73207 times.
✓ Branch 1 taken 146414 times.
219621 for(int32_t i=0; i<2; i++)
18603 {
18604
2/2
✓ Branch 0 taken 73207 times.
✓ Branch 1 taken 73207 times.
146414 if (i == 0)
18605 {
18606
2/2
✓ Branch 0 taken 71239 times.
✓ Branch 1 taken 1968 times.
73207 if(tmpscr2[1].valid!=0)
18607 {
18608
2/2
✓ Branch 0 taken 1587 times.
✓ Branch 1 taken 381 times.
1968 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18609 {
18610
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1587 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1587 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1587 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18612 1587 }
18613 else
18614 {
18615
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18617 }
18618 1968 }
18619 73207 }
18620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146414 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
146414 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
18621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146414 times.
146414 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
18622 {
18623 found=true;
18624 break;
18625 }
18626 146414 }
18627 73207 }
18628
18629
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 73207 times.
73215 if(!found)
18630 {
18631 73207 return;
18632 }
18633
18634
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 switch(type)
18635 {
18636 case cLOCKEDCHEST:
18637 if(!usekey()) return;
18638
18639 setmapflag(mLOCKEDCHEST);
18640 break;
18641
18642 case cCHEST:
18643 8 setmapflag(mCHEST);
18644 8 break;
18645
18646 case cBOSSCHEST:
18647 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18648 // Run Boss Key Script
18649 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18650 for ( int32_t q = 0; q < MAXITEMS; ++q )
18651 {
18652 if ( itemsbuf[q].family == itype_bosskey )
18653 {
18654 key_item = q; break;
18655 }
18656 }
18657 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18658 {
18659 ri = &(itemScriptData[key_item]);
18660 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18661 ri->Clear();
18662 item_doscript[key_item] = 1;
18663 itemscriptInitialised[key_item] = 0;
18664 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18665 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18666 }
18667 setmapflag(mBOSSCHEST);
18668 break;
18669 }
18670
18671 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18672 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18673 8 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
18674 8 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
18675 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18676 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18677
18678
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!itemflag)
18679 {
18680 for(int32_t i=0; i<2; i++)
18681 {
18682 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
18683 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
18684 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
18685 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
18686 }
18687 }
18688
18689
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
18690 {
18691
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
18692 8 }
18693 10441986 }
18694
18695 462355 void HeroClass::checkchest(int32_t type)
18696 {
18697
4/4
✓ Branch 0 taken 318020 times.
✓ Branch 1 taken 144335 times.
✓ Branch 2 taken 144335 times.
✓ Branch 3 taken 173685 times.
462355 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
18698
2/2
✓ Branch 0 taken 14675 times.
✓ Branch 1 taken 447680 times.
462355 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
18699
2/2
✓ Branch 0 taken 14675 times.
✓ Branch 1 taken 447680 times.
462355 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
18700
2/2
✓ Branch 0 taken 14675 times.
✓ Branch 1 taken 447680 times.
462355 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
18701
2/2
✓ Branch 0 taken 29350 times.
✓ Branch 1 taken 433005 times.
462355 if(ischest)
18702 {
18703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433005 times.
433005 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
18704 {
18705 oldcheckchest(type);
18706 return;
18707 }
18708 433005 }
18709
3/4
✓ Branch 0 taken 29350 times.
✓ Branch 1 taken 433005 times.
✓ Branch 2 taken 29350 times.
✗ Branch 3 not taken.
462355 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
18710 {
18711 if(type == cLOCKBLOCK)
18712 oldchecklockblock();
18713 else if(type == cBOSSLOCKBLOCK)
18714 oldcheckbosslockblock();
18715 return;
18716 }
18717
4/6
✓ Branch 0 taken 462355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461599 times.
✓ Branch 3 taken 756 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 461599 times.
462355 if(toogam || z>0 || fakez > 0) return;
18718 461599 zfix bx, by;
18719 461599 zfix bx2, by2;
18720 461599 zfix fx(-1), fy(-1);
18721
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 97018 times.
✓ Branch 2 taken 105214 times.
✓ Branch 3 taken 123259 times.
✓ Branch 4 taken 136108 times.
461599 switch(dir)
18722 {
18723 case up:
18724 97018 by = y + (bigHitbox ? -2 : 6);
18725 97018 by2 = by;
18726 97018 bx = x + 4;
18727 97018 bx2 = bx + 8;
18728 97018 break;
18729 case down:
18730 105214 by = y + 17;
18731 105214 by2 = by;
18732 105214 bx = x + 4;
18733 105214 bx2 = bx + 8;
18734 105214 break;
18735 case left:
18736 123259 by = y + (bigHitbox ? 0 : 8);
18737 123259 by2 = y + 8;
18738 123259 bx = x - 2;
18739 123259 bx2 = x - 2;
18740 123259 break;
18741 case right:
18742 136108 by = y + (bigHitbox ? 0 : 8);
18743 136108 by2 = y + 8;
18744 136108 bx = x + 17;
18745 136108 bx2 = x + 17;
18746 136108 break;
18747 }
18748
18749 461599 int32_t found = -1;
18750 461599 int32_t foundlayer = 0;
18751
18752 461599 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
18753
18754
4/6
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 460728 times.
✓ Branch 2 taken 871 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 871 times.
461599 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
18755 {
18756 871 found = MAPCOMBO(bx,by);
18757 871 fx = bx; fy = by;
18758
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 871 times.
2613 for (int32_t i = 0; i <= 1; ++i)
18759 {
18760
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1357 times.
1742 if(tmpscr2[i].valid!=0)
18761 {
18762
1/2
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
1357 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18763 {
18764
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18765 1357 }
18766 else
18767 {
18768 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18769 }
18770 1357 }
18771 1742 }
18772 871 }
18773
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 460728 times.
461599 if(found<0)
18774 {
18775 460728 cmb = &combobuf[MAPCOMBO(bx2,by2)];
18776
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 460705 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
460728 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
18777 {
18778 23 found = MAPCOMBO(bx2,by2);
18779
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 161 times.
184 for (int32_t i = 0; i <= 6; ++i)
18780 {
18781
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46 times.
161 if(tmpscr2[i].valid!=0)
18782 {
18783
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18784 {
18785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
18786 {
18787 found = -1;
18788 break;
18789 }
18790 46 }
18791 else
18792 {
18793 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
18794 {
18795 found = -1;
18796 break;
18797 }
18798 }
18799 46 }
18800 161 }
18801
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(found != -1)
18802 {
18803 23 fx = bx2; fy = by2;
18804 23 }
18805 23 }
18806 460728 }
18807
18808
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 460705 times.
461599 if(found<0)
18809 {
18810
2/2
✓ Branch 0 taken 460652 times.
✓ Branch 1 taken 2763965 times.
3224617 for(int32_t i=0; i<6; i++)
18811 {
18812 2763965 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
18813
4/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 2763912 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
2763965 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18814 {
18815 53 found = MAPCOMBO2(i,bx,by);
18816
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 265 times.
318 for(int32_t j = i+1; j < 6; ++j)
18817 {
18818
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 53 times.
265 if (tmpscr2[j].valid!=0)
18819 {
18820
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18821 {
18822
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
18823 {
18824 found = -1;
18825 break;
18826 }
18827 53 }
18828 else
18829 {
18830 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
18831 {
18832 found = -1;
18833 break;
18834 }
18835 }
18836 53 }
18837 265 }
18838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(found>-1)
18839 {
18840 53 foundlayer = i+1;
18841 53 fx = bx; fy = by;
18842 53 break;
18843 }
18844 }
18845 2763912 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
18846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2763912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2763912 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
18847 {
18848 found = MAPCOMBO2(i,bx2,by2);
18849 for(int32_t j = i+1; j < 6; ++j)
18850 {
18851 if (tmpscr2[j].valid!=0)
18852 {
18853 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18854 {
18855 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
18856 {
18857 found = -1;
18858 break;
18859 }
18860 }
18861 else
18862 {
18863 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
18864 {
18865 found = -1;
18866 break;
18867 }
18868 }
18869 }
18870 }
18871 if(found>-1)
18872 {
18873 foundlayer = i+1;
18874 fx = bx2; fy = by2;
18875 break;
18876 }
18877 }
18878 2763912 }
18879 460705 }
18880
18881
2/2
✓ Branch 0 taken 947 times.
✓ Branch 1 taken 460652 times.
461599 if(found<0) return;
18882 947 cmb = &combobuf[found];
18883
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
947 switch(dir)
18884 {
18885 case up:
18886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags&cflag10)
18887 return;
18888 947 break;
18889 case down:
18890 if(cmb->usrflags&cflag9)
18891 return;
18892 break;
18893 case left:
18894 if(cmb->usrflags&cflag12)
18895 return;
18896 break;
18897 case right:
18898 if(cmb->usrflags&cflag11)
18899 return;
18900 break;
18901 }
18902 947 int32_t intbtn = cmb->attribytes[2];
18903
18904
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(intbtn) //
18905 {
18906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags & cflag13) //display prompt
18907 {
18908 947 int altcmb = cmb->attributes[2]/10000;
18909 947 prompt_combo = cmb->attributes[1]/10000;
18910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
947 if(altcmb && ((islocked && !can_locked_combo(*cmb))
18911 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
18912 prompt_combo = altcmb;
18913 947 prompt_cset = cmb->attribytes[4];
18914 947 prompt_x = cmb->attrishorts[0];
18915 947 prompt_y = cmb->attrishorts[1];
18916 947 }
18917
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 935 times.
947 if(!getIntBtnInput(intbtn, true, true, false, false))
18918 {
18919 935 return; //Button not pressed
18920 }
18921 12 }
18922 else if(pushing < 8) return; //Not pushing against chest enough
18923
18924
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(ischest)
18925 {
18926
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
18927 12 }
18928 else if(islockblock)
18929 {
18930 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
18931 }
18932
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(intbtn && (cmb->usrflags & cflag13))
18933 12 prompt_combo = 0;
18934 462355 }
18935
18936 3628965 void HeroClass::checkgenpush()
18937 {
18938
4/4
✓ Branch 0 taken 109276 times.
✓ Branch 1 taken 3519689 times.
✓ Branch 2 taken 92119 times.
✓ Branch 3 taken 17157 times.
3628965 if(pushing < 8 || pushing % 8) return;
18939 17157 zfix bx, by;
18940 17157 zfix bx2, by2;
18941
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5147 times.
✓ Branch 2 taken 4328 times.
✓ Branch 3 taken 3509 times.
✓ Branch 4 taken 4173 times.
17157 switch(dir)
18942 {
18943 case up:
18944 5147 by = y + (bigHitbox ? -2 : 6);
18945 5147 by2 = by;
18946 5147 bx = x + 4;
18947 5147 bx2 = bx + 8;
18948 5147 break;
18949 case down:
18950 4328 by = y + 17;
18951 4328 by2 = by;
18952 4328 bx = x + 4;
18953 4328 bx2 = bx + 8;
18954 4328 break;
18955 case left:
18956 3509 by = y + (bigHitbox ? 0 : 8);
18957 3509 by2 = y + 8;
18958 3509 bx = x - 2;
18959 3509 bx2 = x - 2;
18960 3509 break;
18961 case right:
18962 4173 by = y + (bigHitbox ? 0 : 8);
18963 4173 by2 = y + 8;
18964 4173 bx = x + 17;
18965 4173 bx2 = x + 17;
18966 4173 break;
18967 }
18968 17157 auto pos1 = COMBOPOS(bx,by);
18969 17157 auto pos2 = COMBOPOS(bx2,by2);
18970
2/2
✓ Branch 0 taken 17157 times.
✓ Branch 1 taken 120099 times.
137256 for(auto layer = 0; layer < 7; ++layer)
18971 {
18972 120099 mapscr* tmp = FFCore.tempScreens[layer];
18973
18974 120099 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
18975
1/2
✓ Branch 0 taken 120099 times.
✗ Branch 1 not taken.
120099 if(cmb1.triggerflags[1] & combotriggerPUSH)
18976 do_trigger_combo(layer,pos1);
18977
18978
2/2
✓ Branch 0 taken 95865 times.
✓ Branch 1 taken 24234 times.
120099 if(pos1==pos2) continue;
18979
18980 24234 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
18981
1/2
✓ Branch 0 taken 24234 times.
✗ Branch 1 not taken.
24234 if(cmb2.triggerflags[1] & combotriggerPUSH)
18982 do_trigger_combo(layer,pos2);
18983 24234 }
18984
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 16296 times.
17157 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
18985 {
18986 861 word c = tmpscr->numFFC();
18987
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 5878 times.
6739 for(word i=0; i<c; i++)
18988 {
18989
4/4
✓ Branch 0 taken 5719 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 5703 times.
5878 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
18990 {
18991 175 ffcdata& ffc = tmpscr->ffcs[i];
18992 175 newcombo const& cmb3 = combobuf[ffc.getData()];
18993
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(cmb3.triggerflags[1] & combotriggerPUSH)
18994 {
18995 do_trigger_combo_ffc(i);
18996 break;
18997 }
18998 175 }
18999 5878 }
19000 861 }
19001 3628965 }
19002
19003 3628966 void HeroClass::checksigns() //Also checks for generic trigger buttons
19004 {
19005
5/6
✓ Branch 0 taken 3615560 times.
✓ Branch 1 taken 13406 times.
✓ Branch 2 taken 3612283 times.
✓ Branch 3 taken 3277 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3612283 times.
3628966 if(toogam || z>0 || fakez>0) return;
19006
5/6
✓ Branch 0 taken 3587301 times.
✓ Branch 1 taken 24982 times.
✓ Branch 2 taken 44317 times.
✓ Branch 3 taken 3542984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44317 times.
3612283 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
19007 24982 return; //Don't overwrite a message waiting to be dismissed
19008 3587301 zfix bx, by;
19009 3587301 zfix bx2, by2;
19010 3587301 zfix fx(-1), fy(-1);
19011
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 828849 times.
✓ Branch 2 taken 676167 times.
✓ Branch 3 taken 1005840 times.
✓ Branch 4 taken 1076445 times.
3587301 switch(dir)
19012 {
19013 case up:
19014 828849 by = y + (bigHitbox ? -2 : 6);
19015 828849 by2 = by;
19016 828849 bx = x + 4;
19017 828849 bx2 = bx + 8;
19018 828849 break;
19019 case down:
19020 676167 by = y + 17;
19021 676167 by2 = by;
19022 676167 bx = x + 4;
19023 676167 bx2 = bx + 8;
19024 676167 break;
19025 case left:
19026 1005840 by = y + (bigHitbox ? 0 : 8);
19027 1005840 by2 = y + 8;
19028 1005840 bx = x - 2;
19029 1005840 bx2 = x - 2;
19030 1005840 break;
19031 case right:
19032 1076445 by = y + (bigHitbox ? 0 : 8);
19033 1076445 by2 = y + 8;
19034 1076445 bx = x + 17;
19035 1076445 bx2 = x + 17;
19036 1076445 break;
19037 }
19038
19039 3587301 int32_t found = -1;
19040 3587301 int32_t foundffc = -1;
19041 3587301 int32_t found_lyr = 0;
19042 3587301 bool found_sign = false;
19043 3587301 int32_t tmp_cid = MAPCOMBO(bx,by);
19044 3587301 newcombo const* tmp_cmb = &combobuf[tmp_cid];
19045
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3587301 times.
✓ Branch 2 taken 3587301 times.
✗ Branch 3 not taken.
7174602 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19046 3587301 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
19047 {
19048 found = tmp_cid;
19049 fx = bx; fy = by;
19050 for (int32_t i = 0; i <= 1; ++i)
19051 {
19052 if(tmpscr2[i].valid!=0)
19053 {
19054 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19055 {
19056 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19057 }
19058 else
19059 {
19060 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19061 }
19062 }
19063 }
19064 }
19065 3587301 tmp_cid = MAPCOMBO(bx2,by2);
19066 3587301 tmp_cmb = &combobuf[tmp_cid];
19067
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3587301 times.
✓ Branch 2 taken 3587301 times.
✗ Branch 3 not taken.
7174602 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19068 3587301 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
19069 {
19070 found = tmp_cid;
19071 fx = bx2; fy = by2;
19072 for (int32_t i = 0; i <= 1; ++i)
19073 {
19074 if(tmpscr2[i].valid!=0)
19075 {
19076 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19077 {
19078 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19079 }
19080 else
19081 {
19082 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19083 }
19084 }
19085 }
19086 }
19087
19088
2/2
✓ Branch 0 taken 3442825 times.
✓ Branch 1 taken 144476 times.
3587301 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19089 {
19090 144476 word c = tmpscr->numFFC();
19091
2/2
✓ Branch 0 taken 144476 times.
✓ Branch 1 taken 803515 times.
947991 for(word i=0; i<c; i++)
19092 {
19093
4/4
✓ Branch 0 taken 795891 times.
✓ Branch 1 taken 7624 times.
✓ Branch 2 taken 709 times.
✓ Branch 3 taken 795182 times.
803515 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19094 {
19095 8333 ffcdata& ffc = tmpscr->ffcs[i];
19096 8333 tmp_cmb = &combobuf[ffc.getData()];
19097
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8333 times.
8333 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19098 8333 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
19099 {
19100 foundffc = i;
19101 break;
19102 }
19103 8333 }
19104 803515 }
19105 144476 }
19106
19107
2/4
✓ Branch 0 taken 3587301 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3587301 times.
3587301 if(found<0 && foundffc < 0)
19108 {
19109
2/2
✓ Branch 0 taken 3586729 times.
✓ Branch 1 taken 21520946 times.
25107675 for(int32_t i=0; i<6; i++)
19110 {
19111 21520946 tmp_cid = MAPCOMBO2(i,bx,by);
19112 21520946 tmp_cmb = &combobuf[tmp_cid];
19113
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21520946 times.
✓ Branch 2 taken 21520374 times.
✓ Branch 3 taken 572 times.
43041892 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19114 21520946 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
19115 {
19116 572 found = tmp_cid;
19117 572 found_lyr = i+1;
19118 572 fx = bx; fy = by;
19119
3/4
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 440 times.
572 if (i == 0 && tmpscr2[1].valid!=0)
19120 {
19121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
440 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19122 {
19123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19124 440 }
19125 else
19126 {
19127 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19128 }
19129 440 }
19130 572 }
19131 21520946 tmp_cid = MAPCOMBO2(i,bx2,by2);
19132 21520946 tmp_cmb = &combobuf[tmp_cid];
19133
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21520946 times.
✓ Branch 2 taken 21520430 times.
✓ Branch 3 taken 516 times.
43041892 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19134 21520946 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
19135 {
19136 516 found = tmp_cid;
19137 516 found_lyr = i+1;
19138 516 fx = bx2; fy = by2;
19139
3/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 390 times.
516 if (i == 0 && tmpscr2[1].valid!=0)
19140 {
19141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19142 {
19143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19144 390 }
19145 else
19146 {
19147 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19148 }
19149 390 }
19150 516 }
19151
2/2
✓ Branch 0 taken 21520374 times.
✓ Branch 1 taken 572 times.
21520946 if(found>-1) break;
19152 21520374 }
19153 3587301 }
19154
19155
3/4
✓ Branch 0 taken 3586729 times.
✓ Branch 1 taken 572 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3586729 times.
3587301 if(found<0&&foundffc<0) return;
19156
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
19157
19158 572 byte signInput = 0;
19159 572 bool didsign = false;
19160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
572 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
19161 {
19162 switch(dir)
19163 {
19164 case up:
19165 if(cmb.usrflags&cflag10)
19166 goto endsigns;
19167 break;
19168 case down:
19169 if(cmb.usrflags&cflag9)
19170 goto endsigns;
19171 break;
19172 case left:
19173 if(cmb.usrflags&cflag12)
19174 goto endsigns;
19175 break;
19176 case right:
19177 if(cmb.usrflags&cflag11)
19178 goto endsigns;
19179 break;
19180 }
19181 int32_t intbtn = cmb.attribytes[2];
19182
19183 if(intbtn) //
19184 {
19185 signInput = getIntBtnInput(intbtn, true, true, false, false);
19186 if(!signInput)
19187 {
19188 if(cmb.usrflags & cflag13) //display prompt
19189 {
19190 prompt_combo = cmb.attributes[1]/10000;
19191 prompt_cset = cmb.attribytes[4];
19192 prompt_x = cmb.attrishorts[0];
19193 prompt_y = cmb.attrishorts[1];
19194 }
19195 goto endsigns; //Button not pressed
19196 }
19197 }
19198 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
19199
19200 trigger_sign(cmb);
19201 didsign = true;
19202 }
19203 endsigns:
19204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 if(!cmb.triggerbtn) return;
19205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
19206
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 35 times.
572 switch(dir)
19207 {
19208 case down:
19209
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
19210 return;
19211 91 break;
19212 case up:
19213
1/2
✓ Branch 0 taken 400 times.
✗ Branch 1 not taken.
400 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
19214 return;
19215 400 break;
19216 case right:
19217
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
19218 return;
19219 46 break;
19220 case left:
19221
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
19222 return;
19223 35 break;
19224 }
19225
3/4
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 561 times.
572 if(getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput))
19226 {
19227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (foundffc >= 0)
19228 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
19229 else
19230 11 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
19231 11 }
19232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 else if(cmb.type == cBUTTONPROMPT)
19233 {
19234 prompt_combo = cmb.attributes[0]/10000;
19235 prompt_cset = cmb.attribytes[0];
19236 prompt_x = cmb.attrishorts[0];
19237 prompt_y = cmb.attrishorts[1];
19238 }
19239
1/2
✓ Branch 0 taken 561 times.
✗ Branch 1 not taken.
561 else if(cmb.prompt_cid)
19240 {
19241 561 prompt_combo = cmb.prompt_cid;
19242 561 prompt_cset = cmb.prompt_cs;
19243 561 prompt_x = cmb.prompt_x;
19244 561 prompt_y = cmb.prompt_y;
19245 561 }
19246 3628966 }
19247
19248 3625005 void HeroClass::checklocked()
19249 {
19250
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3611599 times.
3625005 if(toogam) return; //Walk through walls.
19251
19252
2/2
✓ Branch 0 taken 2294633 times.
✓ Branch 1 taken 1316966 times.
3611599 if(!isdungeon()) return;
19253
19254
3/4
✓ Branch 0 taken 2294633 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4314 times.
✓ Branch 3 taken 2290319 times.
2294633 if( !diagonalMovement && pushing!=8) return;
19255 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
19256 */
19257
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4314 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
19258
19259
19260 4314 bool found = false;
19261
2/2
✓ Branch 0 taken 17256 times.
✓ Branch 1 taken 4314 times.
21570 for ( int32_t q = 0; q < 4; q++ ) {
19262
4/4
✓ Branch 0 taken 16740 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 16494 times.
17256 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
19263 17256 }
19264
19265
2/2
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 3583 times.
4314 if ( !found ) return;
19266
19267 731 int32_t si = (currmap<<7) + currscr;
19268 731 int32_t di = 0;
19269
19270
19271
19272
2/4
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 731 times.
731 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
19273 {
19274 //Up door
19275 if ( y <= 32 && x >= 112 && x <= 128 )
19276 {
19277 if (
19278 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
19279
19280 )
19281 {
19282 di = nextscr(up);
19283 if(tmpscr->door[0]==dLOCKED)
19284 {
19285 if(usekey())
19286 {
19287 putdoor(scrollbuf,0,up,dUNLOCKED);
19288 tmpscr->door[0]=dUNLOCKED;
19289 setmapflag(si, mDOOR_UP);
19290
19291 if(di != 0xFFFF)
19292 setmapflag(di, mDOOR_DOWN);
19293 sfx(WAV_DOOR);
19294 markBmap(-1);
19295 }
19296 else return;
19297 }
19298 else if(tmpscr->door[0]==dBOSS)
19299 {
19300 if(game->lvlitems[dlevel]&liBOSSKEY)
19301 {
19302 putdoor(scrollbuf,0,up,dOPENBOSS);
19303 tmpscr->door[0]=dOPENBOSS;
19304 setmapflag(si, mDOOR_UP);
19305
19306 if(di != 0xFFFF)
19307 setmapflag(di, mDOOR_DOWN);
19308 sfx(WAV_DOOR);
19309 markBmap(-1);
19310 // Run Boss Key Script
19311 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19312 for ( int32_t q = 0; q < MAXITEMS; ++q )
19313 {
19314 if ( itemsbuf[q].family == itype_bosskey )
19315 {
19316 key_item = q; break;
19317 }
19318 }
19319 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19320 {
19321 ri = &(itemScriptData[key_item]);
19322 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19323 ri->Clear();
19324 item_doscript[key_item] = 1;
19325 itemscriptInitialised[key_item] = 0;
19326 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19327 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19328 }
19329 }
19330 else return;
19331
19332 }
19333
19334 }
19335 }
19336 //Down
19337 if ( y >= 128 && x >= 112 && x <= 128 )
19338 {
19339 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
19340 {
19341 di = nextscr(down);
19342 if(tmpscr->door[1]==dLOCKED)
19343 {
19344 if(usekey())
19345 {
19346 putdoor(scrollbuf,0,down,dUNLOCKED);
19347 tmpscr->door[1]=dUNLOCKED;
19348 setmapflag(si, mDOOR_DOWN);
19349
19350 if(di != 0xFFFF)
19351 setmapflag(di, mDOOR_UP);
19352 sfx(WAV_DOOR);
19353 markBmap(-1);
19354 }
19355 else return;
19356 }
19357 else if(tmpscr->door[1]==dBOSS)
19358 {
19359 if(game->lvlitems[dlevel]&liBOSSKEY)
19360 {
19361 putdoor(scrollbuf,0,down,dOPENBOSS);
19362 tmpscr->door[1]=dOPENBOSS;
19363 setmapflag(si, mDOOR_DOWN);
19364
19365 if(di != 0xFFFF)
19366 setmapflag(di, mDOOR_UP);
19367 sfx(WAV_DOOR);
19368 markBmap(-1);
19369 // Run Boss Key Script
19370 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19371 for ( int32_t q = 0; q < MAXITEMS; ++q )
19372 {
19373 if ( itemsbuf[q].family == itype_bosskey )
19374 {
19375 key_item = q; break;
19376 }
19377 }
19378 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19379 {
19380 ri = &(itemScriptData[key_item]);
19381 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19382 ri->Clear();
19383 item_doscript[key_item] = 1;
19384 itemscriptInitialised[key_item] = 0;
19385 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19386 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19387 }
19388 }
19389 else return;
19390 }
19391 }
19392 }
19393 //left
19394 if ( y > 72 && y < 88 && x <= 32 )
19395 {
19396 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
19397 {
19398 di = nextscr(left);
19399 if(tmpscr->door[2]==dLOCKED)
19400 {
19401 if(usekey())
19402 {
19403 putdoor(scrollbuf,0,left,dUNLOCKED);
19404 tmpscr->door[2]=dUNLOCKED;
19405 setmapflag(si, mDOOR_LEFT);
19406
19407 if(di != 0xFFFF)
19408 setmapflag(di, mDOOR_RIGHT);
19409 sfx(WAV_DOOR);
19410 markBmap(-1);
19411 }
19412 else return;
19413 }
19414 else if(tmpscr->door[2]==dBOSS)
19415 {
19416 if(game->lvlitems[dlevel]&liBOSSKEY)
19417 {
19418 putdoor(scrollbuf,0,left,dOPENBOSS);
19419 tmpscr->door[2]=dOPENBOSS;
19420 setmapflag(si, mDOOR_LEFT);
19421
19422 if(di != 0xFFFF)
19423 setmapflag(di, mDOOR_RIGHT);
19424 sfx(WAV_DOOR);
19425 markBmap(-1);
19426 // Run Boss Key Script
19427 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19428 for ( int32_t q = 0; q < MAXITEMS; ++q )
19429 {
19430 if ( itemsbuf[q].family == itype_bosskey )
19431 {
19432 key_item = q; break;
19433 }
19434 }
19435 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19436 {
19437 ri = &(itemScriptData[key_item]);
19438 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19439 ri->Clear();
19440 item_doscript[key_item] = 1;
19441 itemscriptInitialised[key_item] = 0;
19442 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19443 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19444 }
19445 }
19446 else return;
19447 }
19448 }
19449 }
19450
19451
19452 //right
19453 if ( ( y > 72 && y < 88 ) && x >= 208 )
19454 //!( (y<=72||y>=88) && x<206 ) )
19455 //y<=72||y>=88):y!=80) || x<208)
19456 {
19457 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
19458 {
19459 di = nextscr(right);
19460 if(tmpscr->door[right]==dLOCKED)
19461 {
19462 if(usekey())
19463 {
19464 putdoor(scrollbuf,0,right,dUNLOCKED);
19465 tmpscr->door[3]=dUNLOCKED;
19466 setmapflag(si, mDOOR_RIGHT);
19467
19468 if(di != 0xFFFF)
19469 setmapflag(di, mDOOR_LEFT);
19470 sfx(WAV_DOOR);
19471 markBmap(-1);
19472 }
19473 else return;
19474 }
19475 else if(tmpscr->door[right]==dBOSS)
19476 {
19477 if(game->lvlitems[dlevel]&liBOSSKEY)
19478 {
19479 putdoor(scrollbuf,0,right,dOPENBOSS);
19480 tmpscr->door[3]=dOPENBOSS;
19481 setmapflag(si, mDOOR_RIGHT);
19482
19483 if(di != 0xFFFF)
19484 setmapflag(di, mDOOR_LEFT);
19485 sfx(WAV_DOOR);
19486 markBmap(-1);
19487 // Run Boss Key Script
19488 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19489 for ( int32_t q = 0; q < MAXITEMS; ++q )
19490 {
19491 if ( itemsbuf[q].family == itype_bosskey )
19492 {
19493 key_item = q; break;
19494 }
19495 }
19496 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19497 {
19498 ri = &(itemScriptData[key_item]);
19499 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19500 ri->Clear();
19501 item_doscript[key_item] = 1;
19502 itemscriptInitialised[key_item] = 0;
19503 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19504 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19505 }
19506 }
19507 else return;
19508 }
19509
19510 }
19511 }
19512 }
19513 else
19514 {
19515 //orthogonal movement
19516 //Up door
19517
4/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 587 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 83 times.
731 if ( y<=32 && x == 120 )
19518 //!( y>32 && (x!=120) ))
19519 {
19520
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1 times.
83 switch ( dir )
19521 {
19522 case up:
19523 case r_up:
19524 case l_up:
19525 {
19526 82 di = nextscr(up);
19527
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 22 times.
82 if(tmpscr->door[0]==dLOCKED)
19528 {
19529
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 3 times.
60 if(usekey())
19530 {
19531 57 putdoor(scrollbuf,0,up,dUNLOCKED);
19532 57 tmpscr->door[0]=dUNLOCKED;
19533 57 setmapflag(si, mDOOR_UP);
19534
19535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(di != 0xFFFF)
19536 57 setmapflag(di, mDOOR_DOWN);
19537 57 sfx(WAV_DOOR);
19538 57 markBmap(-1);
19539 57 }
19540 3 else return;
19541 57 }
19542
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 15 times.
22 else if(tmpscr->door[0]==dBOSS)
19543 {
19544
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(game->lvlitems[dlevel]&liBOSSKEY)
19545 {
19546 14 putdoor(scrollbuf,0,up,dOPENBOSS);
19547 14 tmpscr->door[0]=dOPENBOSS;
19548 14 setmapflag(si, mDOOR_UP);
19549
19550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(di != 0xFFFF)
19551 14 setmapflag(di, mDOOR_DOWN);
19552 14 sfx(WAV_DOOR);
19553 14 markBmap(-1);
19554 // Run Boss Key Script
19555 14 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 for ( int32_t q = 0; q < MAXITEMS; ++q )
19557 {
19558
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
952 if ( itemsbuf[q].family == itype_bosskey )
19559 {
19560 14 key_item = q; break;
19561 }
19562 938 }
19563
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19564 {
19565 ri = &(itemScriptData[key_item]);
19566 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19567 ri->Clear();
19568 item_doscript[key_item] = 1;
19569 itemscriptInitialised[key_item] = 0;
19570 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19571 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19572 }
19573 14 }
19574 1 else return;
19575 14 }
19576 78 break;
19577 }
19578 1 default: break;
19579
19580 }
19581 79 }
19582 //Down
19583
4/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 638 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 23 times.
727 if ( y >= 128 && x == 120 )
19584 //!(y<128 && (x!=120) ) )
19585 {
19586
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3 times.
23 switch(dir)
19587 {
19588 case down:
19589 case l_down:
19590 case r_down:
19591 {
19592 20 di = nextscr(down);
19593
19594
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9 times.
20 if(tmpscr->door[1]==dLOCKED)
19595 {
19596
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(usekey())
19597 {
19598 10 putdoor(scrollbuf,0,down,dUNLOCKED);
19599 10 tmpscr->door[1]=dUNLOCKED;
19600 10 setmapflag(si, mDOOR_DOWN);
19601
19602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(di != 0xFFFF)
19603 10 setmapflag(di, mDOOR_UP);
19604 10 sfx(WAV_DOOR);
19605 10 markBmap(-1);
19606 10 }
19607 1 else return;
19608 10 }
19609
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 else if(tmpscr->door[1]==dBOSS)
19610 {
19611
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19612 {
19613 4 putdoor(scrollbuf,0,down,dOPENBOSS);
19614 4 tmpscr->door[1]=dOPENBOSS;
19615 4 setmapflag(si, mDOOR_DOWN);
19616
19617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
19618 4 setmapflag(di, mDOOR_UP);
19619 4 sfx(WAV_DOOR);
19620 4 markBmap(-1);
19621 // Run Boss Key Script
19622 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
19624 {
19625
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
19626 {
19627 4 key_item = q; break;
19628 }
19629 268 }
19630
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19631 {
19632 ri = &(itemScriptData[key_item]);
19633 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19634 ri->Clear();
19635 item_doscript[key_item] = 1;
19636 itemscriptInitialised[key_item] = 0;
19637 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19638 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19639 }
19640 4 }
19641 1 else return;
19642 4 }
19643 18 break;
19644 }
19645 3 default: break;
19646 }
19647 21 }
19648 //left
19649
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 40 times.
725 if ( y == 80 && x <= 32 )
19650 //!( (y!=80) && x>32 ) )
19651 {
19652
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 7 times.
40 switch(dir)
19653 {
19654 case left:
19655 case l_up:
19656 case l_down:
19657 {
19658 33 di = nextscr(left);
19659
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11 times.
33 if(tmpscr->door[2]==dLOCKED)
19660 {
19661
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1 times.
22 if(usekey())
19662 {
19663 21 putdoor(scrollbuf,0,left,dUNLOCKED);
19664 21 tmpscr->door[2]=dUNLOCKED;
19665 21 setmapflag(si, mDOOR_LEFT);
19666
19667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(di != 0xFFFF)
19668 21 setmapflag(di, mDOOR_RIGHT);
19669 21 sfx(WAV_DOOR);
19670 21 markBmap(-1);
19671 21 }
19672 1 else return;
19673 21 }
19674
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 else if(tmpscr->door[2]==dBOSS)
19675 {
19676
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19677 {
19678 4 putdoor(scrollbuf,0,left,dOPENBOSS);
19679 4 tmpscr->door[2]=dOPENBOSS;
19680 4 setmapflag(si, mDOOR_LEFT);
19681
19682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
19683 4 setmapflag(di, mDOOR_RIGHT);
19684 4 sfx(WAV_DOOR);
19685 4 markBmap(-1);
19686 // Run Boss Key Script
19687 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
19689 {
19690
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
19691 {
19692 4 key_item = q; break;
19693 }
19694 268 }
19695
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19696 {
19697 ri = &(itemScriptData[key_item]);
19698 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19699 ri->Clear();
19700 item_doscript[key_item] = 1;
19701 itemscriptInitialised[key_item] = 0;
19702 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19703 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19704 }
19705 4 }
19706 1 else return;
19707 4 }
19708
19709 31 break;
19710
19711 }
19712 7 default: break;
19713 }
19714 38 }
19715 //right
19716
4/4
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 49 times.
723 if ( y == 80 && x >= 208 )
19717 //!((y!=80) && x<208 ) )
19718 {
19719
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 2 times.
49 switch(dir)
19720 {
19721 case right:
19722 case r_down:
19723 case r_up:
19724 {
19725 47 di = nextscr(right);
19726
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 17 times.
47 if(tmpscr->door[3]==dLOCKED)
19727 {
19728
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(usekey())
19729 {
19730 30 putdoor(scrollbuf,0,right,dUNLOCKED);
19731 30 tmpscr->door[3]=dUNLOCKED;
19732 30 setmapflag(si, mDOOR_RIGHT);
19733
19734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(di != 0xFFFF)
19735 30 setmapflag(di, mDOOR_LEFT);
19736 30 sfx(WAV_DOOR);
19737 30 markBmap(-1);
19738 30 }
19739 else return;
19740 30 }
19741
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 else if(tmpscr->door[3]==dBOSS)
19742 {
19743
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(game->lvlitems[dlevel]&liBOSSKEY)
19744 {
19745 7 putdoor(scrollbuf,0,right,dOPENBOSS);
19746 7 tmpscr->door[3]=dOPENBOSS;
19747 7 setmapflag(si, mDOOR_RIGHT);
19748
19749
19750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
19751 7 setmapflag(di, mDOOR_LEFT);
19752 7 sfx(WAV_DOOR);
19753 7 markBmap(-1);
19754 // Run Boss Key Script
19755 7 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 for ( int32_t q = 0; q < MAXITEMS; ++q )
19757 {
19758
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if ( itemsbuf[q].family == itype_bosskey )
19759 {
19760 7 key_item = q; break;
19761 }
19762 469 }
19763
2/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
19764 {
19765 ri = &(itemScriptData[key_item]);
19766 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19767 ri->Clear();
19768 item_doscript[key_item] = 1;
19769 itemscriptInitialised[key_item] = 0;
19770 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19771 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19772 }
19773
19774 7 }
19775 1 else return;
19776 7 }
19777
19778
19779 46 break;
19780 }
19781 2 default: break;
19782
19783 }
19784 48 }
19785 }
19786 3625005 }
19787
19788 3625005 void HeroClass::checkswordtap()
19789 {
19790
6/6
✓ Branch 0 taken 2068451 times.
✓ Branch 1 taken 1556554 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 2066538 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 11 times.
3625005 if(attack!=wSword || charging<=0 || pushing<8) return;
19791
19792 11 int32_t bx=x;
19793 11 int32_t by=y+8;
19794
19795
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(dir)
19796 {
19797 case up:
19798
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!Up()) return;
19799
19800 11 by-=16;
19801 11 break;
19802
19803 case down:
19804 if(!Down()) return;
19805
19806 by+=16;
19807 bx+=8;
19808 break;
19809
19810 case left:
19811 if(!Left()) return;
19812
19813 bx-=16;
19814 by+=8;
19815 break;
19816
19817 case right:
19818 if(!Right()) return;
19819
19820 bx+=16;
19821 by+=8;
19822 break;
19823 }
19824
19825
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
19826
19827 11 attackclk=SWORDTAPFRAME;
19828 11 pushing=-8; //16 frames between taps
19829 11 tapping=true;
19830
19831 11 int32_t type = COMBOTYPE(bx,by);
19832
19833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!isCuttableType(type))
19834 {
19835
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
19836
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
19837
19838 // Layers
19839
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11 times.
77 for(int32_t i=0; i < 6; i++)
19840
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
132 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
19841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
19842
19843
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
19844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->door[i]==dBOMB && i==dir)
19845 switch(i)
19846 {
19847 case up:
19848 case down:
19849 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
19850
19851 break;
19852
19853 case left:
19854 case right:
19855 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
19856
19857 break;
19858 }
19859
19860 11 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
19861 11 }
19862
19863 3625005 }
19864
19865 13458 void HeroClass::fairycircle(int32_t type)
19866 {
19867
2/2
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 1907 times.
13458 if(fairyclk==0)
19868 {
19869
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1907 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1907 switch(type)
19870 {
19871 case REFILL_LIFE:
19872
2/2
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 71 times.
1907 if(didstuff&did_fairy) return;
19873
19874 71 didstuff|=did_fairy;
19875 71 break;
19876
19877 case REFILL_MAGIC:
19878 if(didstuff&did_magic) return;
19879
19880 didstuff|=did_magic;
19881 break;
19882
19883 case REFILL_ALL:
19884 if(didstuff&did_all) return;
19885
19886 didstuff|=did_all;
19887 }
19888
19889 71 refill_what=type;
19890 71 refill_why=REFILL_FAIRY;
19891 71 StartRefill(type);
19892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
19893 71 else {action=freeze; FFCore.setHeroAction(freeze);}
19894 71 holdclk=0;
19895 71 hopclk=0;
19896 71 }
19897
19898 11622 ++fairyclk;
19899
19900
2/2
✓ Branch 0 taken 5871 times.
✓ Branch 1 taken 5751 times.
11622 if(refilling!=REFILL_FAIRYDONE)
19901 {
19902
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 71 times.
5871 if(!refill())
19903 71 refilling=REFILL_FAIRYDONE;
19904 5871 }
19905
19906
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 71 times.
5751 else if(++holdclk>80)
19907 {
19908 71 reset_swordcharge();
19909 71 attackclk=0;
19910 71 action=none; FFCore.setHeroAction(none);
19911 71 fairyclk=0;
19912 71 holdclk=0;
19913 71 refill_why = 0;
19914 71 refilling=REFILL_NONE;
19915 71 map_bkgsfx(true);
19916 71 }
19917 13458 }
19918
19919 294271 int32_t touchcombo(int32_t x,int32_t y)
19920 {
19921
2/2
✓ Branch 0 taken 588542 times.
✓ Branch 1 taken 294271 times.
882813 for (int32_t i = 0; i <= 1; ++i)
19922 {
19923
2/2
✓ Branch 0 taken 432302 times.
✓ Branch 1 taken 156240 times.
588542 if(tmpscr2[i].valid!=0)
19924 {
19925
2/2
✓ Branch 0 taken 150909 times.
✓ Branch 1 taken 5331 times.
156240 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19926 {
19927
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150909 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19928 150909 }
19929 else
19930 {
19931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5331 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5331 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19932 }
19933 156240 }
19934 588542 }
19935
2/2
✓ Branch 0 taken 293782 times.
✓ Branch 1 taken 489 times.
294271 if (!_effectflag(x,y,1, -1)) return 0;
19936 293782 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
19937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293782 times.
293782 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19938 return 0;
19939
3/3
✓ Branch 0 taken 2743 times.
✓ Branch 1 taken 289752 times.
✓ Branch 2 taken 1287 times.
293782 switch(cmb.type)
19940 {
19941 case cBSGRAVE:
19942 case cGRAVE:
19943
3/4
✓ Branch 0 taken 1814 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 1814 times.
✗ Branch 3 not taken.
2743 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
19944 {
19945 929 break;
19946 }
19947
19948 [[fallthrough]];
19949 case cARMOS:
19950 {
19951 3101 return cmb.type;
19952 }
19953 }
19954
19955 290681 return 0;
19956 294271 }
19957
19958 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
19959 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
19960
19961 static int32_t GridX(int32_t x)
19962 {
19963 return (x >> 4) << 4;
19964 }
19965
19966 //Snaps 'y' to the combo grid
19967 //Equivalent to calling ComboY(ComboAt(foo,y));
19968 static int32_t GridY(int32_t y)
19969 {
19970 return (y >> 4) << 4;
19971 }
19972
19973 int32_t grabComboFromPos(int32_t pos, int32_t type)
19974 {
19975 for(int32_t lyr = 6; lyr > -1; --lyr)
19976 {
19977 int32_t id = FFCore.tempScreens[lyr]->data[pos];
19978 if(combobuf[id].type == type)
19979 return id;
19980 }
19981 return -1;
19982 }
19983
19984 static int32_t typeMap[176];
19985 static int32_t istrig[176];
19986 static const int32_t SPTYPE_SOLID = -1;
19987 #define SP_VISITED 0x1
19988 #define SPFLAG(dir) (0x2<<dir)
19989 #define BEAM_AGE_LIMIT 32
19990 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
19991 {
19992 int32_t trigflag = set ? (1 << (set-1)) : ~0;
19993 if(spotdir > 3) return; //invalid dir
19994 bool doAge = true;
19995 byte f = 0;
19996 while(unsigned(curpos) < 176)
19997 {
19998 bool block_light = false;
19999 f = SPFLAG(spotdir);
20000 if((grid[curpos] & f) != f)
20001 {
20002 grid[curpos] |= f;
20003 istrig[curpos] |= trigflag;
20004 doAge = false;
20005 age = 0;
20006 }
20007 switch(spotdir)
20008 {
20009 case up:
20010 curpos -= 0x10;
20011 break;
20012 case down:
20013 curpos += 0x10;
20014 break;
20015 case left:
20016 if(!(curpos%0x10))
20017 curpos = -1;
20018 else --curpos;
20019 break;
20020 case right:
20021 ++curpos;
20022 if(!(curpos%0x10))
20023 curpos = -1;
20024 break;
20025 }
20026 if(unsigned(curpos) >= 176) break;
20027 switch(typeMap[curpos])
20028 {
20029 case SPTYPE_SOLID: case cBLOCKALL:
20030 curpos = -1;
20031 break;
20032 }
20033 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
20034 curpos = -1;
20035 if(unsigned(curpos) >= 176) break;
20036
20037 f = SPFLAG(oppositeDir[spotdir]);
20038 if((grid[curpos] & f) != f)
20039 {
20040 grid[curpos] |= f;
20041 istrig[curpos] |= trigflag;
20042 doAge = false;
20043 age = 0;
20044 }
20045 if(doAge)
20046 {
20047 if(++age > BEAM_AGE_LIMIT)
20048 break;
20049 }
20050 else doAge = true;
20051
20052 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
20053 spotdir = dir;
20054 else switch(typeMap[curpos])
20055 {
20056 case cLIGHTTARGET:
20057 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
20058 return;
20059 case cMIRROR:
20060 spotdir = oppositeDir[spotdir];
20061 break;
20062 case cMIRRORSLASH:
20063 switch(spotdir)
20064 {
20065 case up:
20066 spotdir = right; break;
20067 case right:
20068 spotdir = up; break;
20069 case down:
20070 spotdir = left; break;
20071 case left:
20072 spotdir = down; break;
20073 }
20074 break;
20075 case cMIRRORBACKSLASH:
20076 switch(spotdir)
20077 {
20078 case up:
20079 spotdir = left; break;
20080 case left:
20081 spotdir = up; break;
20082 case down:
20083 spotdir = right; break;
20084 case right:
20085 spotdir = down; break;
20086 }
20087 break;
20088 case cMAGICPRISM:
20089 for(byte d = 0; d < 4; ++d)
20090 {
20091 if(d == oppositeDir[spotdir]) continue;
20092 handleBeam(grid, age, d, curpos, set, block, refl);
20093 }
20094 return;
20095 case cMAGICPRISM4:
20096 for(byte d = 0; d < 4; ++d)
20097 {
20098 handleBeam(grid, age, d, curpos, set, block, refl);
20099 }
20100 return;
20101 }
20102 }
20103 }
20104
20105 3628643 void HeroClass::handleSpotlights()
20106 {
20107 typedef byte spot_t;
20108 //Store each different tile/color as grids
20109 3628643 std::map<int32_t, spot_t*> maps;
20110
1/2
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
3628643 int32_t shieldid = getCurrentShield(false);
20111
2/2
✓ Branch 0 taken 3137895 times.
✓ Branch 1 taken 490748 times.
3628643 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
20112
3/4
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490748 times.
✓ Branch 3 taken 3137895 times.
3628643 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
20113
3/6
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3628643 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3628643 times.
✗ Branch 5 not taken.
3628643 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
20114 3628643 memset(istrig, 0, sizeof(istrig));
20115
1/2
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
3628643 clear_bitmap(lightbeam_bmp);
20116
20117
2/2
✓ Branch 0 taken 638641168 times.
✓ Branch 1 taken 3628643 times.
642269811 for(size_t pos = 0; pos < 176; ++pos)
20118 {
20119 638641168 typeMap[pos] = 0;
20120
2/2
✓ Branch 0 taken 638469049 times.
✓ Branch 1 taken 4470487691 times.
5108956740 for(int32_t lyr = 6; lyr > -1; --lyr)
20121 {
20122 4470487691 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
20123
2/3
✓ Branch 0 taken 172119 times.
✓ Branch 1 taken 4470315572 times.
✗ Branch 2 not taken.
4470487691 switch(cmb->type)
20124 {
20125 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
20126 case cMAGICPRISM: case cMAGICPRISM4:
20127 case cBLOCKALL: case cLIGHTTARGET:
20128 172119 typeMap[pos] = cmb->type;
20129 172119 break;
20130 case cGLASS:
20131 typeMap[pos] = 0;
20132 break;
20133 default:
20134 {
20135
4/4
✓ Branch 0 taken 1915750900 times.
✓ Branch 1 taken 2554564672 times.
✓ Branch 2 taken 1533008333 times.
✓ Branch 3 taken 382742567 times.
4470315572 if(lyr < 3 && (cmb->walk & 0xF))
20136 {
20137 382742567 typeMap[pos] = SPTYPE_SOLID;
20138 382742567 }
20139 4470315572 continue; //next layer
20140 }
20141 }
20142 172119 break; //hit a combo type
20143 }
20144 638641168 }
20145
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 3628513 times.
3628643 if(unsigned(heropos) < 176)
20146 {
20147
2/2
✓ Branch 0 taken 287179 times.
✓ Branch 1 taken 3341334 times.
3628513 switch(typeMap[heropos])
20148 {
20149 case SPTYPE_SOLID: case cBLOCKALL:
20150 287179 heropos = -1; //Blocked from hitting player
20151 287179 }
20152 3628513 }
20153
20154
2/2
✓ Branch 0 taken 25400501 times.
✓ Branch 1 taken 3628643 times.
29029144 for(size_t layer = 0; layer < 7; ++layer)
20155 {
20156 25400501 mapscr* curlayer = FFCore.tempScreens[layer];
20157
2/2
✓ Branch 0 taken 4470488176 times.
✓ Branch 1 taken 25400501 times.
4495888677 for(size_t pos = 0; pos < 176; ++pos)
20158 {
20159 //For each spotlight combo on each layer...
20160 4470488176 newcombo const& cmb = combobuf[curlayer->data[pos]];
20161
1/2
✓ Branch 0 taken 4470488176 times.
✗ Branch 1 not taken.
4470488176 if(cmb.type == cSPOTLIGHT)
20162 {
20163 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
20164 int32_t id = (cmb.usrflags&cflag1)
20165 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
20166 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
20167 if(!id) continue;
20168 // zprint2("ID = %ld\n", id);
20169 //Get the grid array for this tile/color
20170 spot_t* grid;
20171 if(maps[id])
20172 grid = maps[id];
20173 else
20174 {
20175 grid = new spot_t[176];
20176 memset(grid, 0, sizeof(spot_t)*176);
20177 maps[id] = grid;
20178 }
20179 byte spotdir = cmb.attribytes[0];
20180 int32_t curpos = pos;
20181 if(spotdir > 3)
20182 {
20183 grid[curpos] |= SP_VISITED;
20184 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
20185 }
20186 if(refl && curpos == heropos)
20187 {
20188 spotdir = dir;
20189 }
20190 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
20191 }
20192 4470488176 }
20193 25400501 }
20194
20195 //Draw visuals
20196
1/2
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
3628643 for(auto it = maps.begin(); it != maps.end();)
20197 {
20198 int32_t id = it->first;
20199 spot_t* grid = it->second;
20200 //
20201 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
20202 int32_t tile = (id&0xFFFFFF);
20203 int32_t cs = (id>>24);
20204 byte c_inner = ((-id)&0x0000FF);
20205 byte c_middle = ((-id)&0x00FF00)>>8;
20206 byte c_outter = ((-id)&0xFF0000)>>16;
20207 //{ Setup color bitmap
20208 BITMAP* cbmp = NULL;
20209 if(id < 0)
20210 {
20211 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
20212 cbmp = create_bitmap_ex(8, 16*t_max, 16);
20213 clear_bitmap(cbmp);
20214 for(size_t q = 1; q < t_max; ++q)
20215 {
20216 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
20217 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
20218 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
20219 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
20220 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
20221 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
20222 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
20223 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
20224 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
20225 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
20226 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
20227 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
20228 }
20229 //t_gr
20230 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
20231 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
20232 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
20233 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
20234 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
20235 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
20236 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
20237 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
20238 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
20239 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
20240 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
20241 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
20242 //t_up
20243 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
20244 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
20245 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
20246 //t_down
20247 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
20248 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
20249 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
20250 //t_left
20251 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
20252 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
20253 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
20254 //t_right
20255 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
20256 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
20257 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
20258 //t_uleft
20259 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
20260 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
20261 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
20262 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
20263 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
20264 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
20265 //t_uright
20266 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
20267 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
20268 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
20269 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
20270 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
20271 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
20272 //t_dleft
20273 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
20274 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
20275 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
20276 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
20277 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
20278 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
20279 //t_dright
20280 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
20281 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
20282 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
20283 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
20284 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
20285 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
20286 //t_vert
20287 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
20288 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
20289 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
20290 //t_horz
20291 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
20292 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
20293 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
20294 //t_notup
20295 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
20296 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
20297 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
20298 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
20299 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
20300 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
20301 //t_notdown
20302 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
20303 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
20304 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
20305 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
20306 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
20307 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
20308 //t_notleft
20309 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
20310 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
20311 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
20312 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
20313 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
20314 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
20315 //t_notright
20316 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
20317 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
20318 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
20319 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
20320 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
20321 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
20322 //t_all
20323 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
20324 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
20325 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
20326 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
20327 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
20328 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
20329 }
20330 //}
20331 //
20332 for(size_t pos = 0; pos < 176; ++pos)
20333 {
20334 int32_t offs = -1;
20335 switch(grid[pos]>>1)
20336 {
20337 case 0: default:
20338 if(grid[pos])
20339 {
20340 offs = t_gr;
20341 break;
20342 }
20343 continue; //no draw this pos
20344 case 0b0001:
20345 offs = t_up;
20346 break;
20347 case 0b0010:
20348 offs = t_down;
20349 break;
20350 case 0b0100:
20351 offs = t_left;
20352 break;
20353 case 0b1000:
20354 offs = t_right;
20355 break;
20356 case 0b0011:
20357 offs = t_vert;
20358 break;
20359 case 0b1100:
20360 offs = t_horz;
20361 break;
20362 case 0b0101:
20363 offs = t_uleft;
20364 break;
20365 case 0b1001:
20366 offs = t_uright;
20367 break;
20368 case 0b0110:
20369 offs = t_dleft;
20370 break;
20371 case 0b1010:
20372 offs = t_dright;
20373 break;
20374 case 0b1110:
20375 offs = t_notup;
20376 break;
20377 case 0b1101:
20378 offs = t_notdown;
20379 break;
20380 case 0b1011:
20381 offs = t_notleft;
20382 break;
20383 case 0b0111:
20384 offs = t_notright;
20385 break;
20386 case 0b1111:
20387 offs = t_all;
20388 break;
20389 }
20390 if(id > 0) //tile
20391 {
20392 //Draw 'tile' at 'pos'
20393 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
20394 }
20395 else //colors
20396 {
20397 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
20398 }
20399 }
20400 //
20401 if(cbmp) destroy_bitmap(cbmp);
20402 delete[] it->second;
20403 it = maps.erase(it);
20404 }
20405 //Check triggers
20406 3628643 bool hastrigs = false, istrigged = true;
20407
1/2
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
3628643 bool alltrig = getmapflag(mLIGHTBEAM);
20408
2/2
✓ Branch 0 taken 25400501 times.
✓ Branch 1 taken 3628643 times.
29029144 for(size_t layer = 0; layer < 7; ++layer)
20409 {
20410 25400501 mapscr* curlayer = FFCore.tempScreens[layer];
20411
2/2
✓ Branch 0 taken 4470488176 times.
✓ Branch 1 taken 25400501 times.
4495888677 for(size_t pos = 0; pos < 176; ++pos)
20412 {
20413 4470488176 newcombo const* cmb = &combobuf[curlayer->data[pos]];
20414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4470488176 times.
4470488176 if(cmb->type == cLIGHTTARGET)
20415 {
20416 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20417 hastrigs = true;
20418 bool trigged = (istrig[pos]&trigflag);
20419 if(cmb->usrflags&cflag2) //Invert
20420 trigged = !trigged;
20421 if(cmb->usrflags&cflag1) //Solved Version
20422 {
20423 if(!(alltrig || trigged)) //Revert
20424 {
20425 curlayer->data[pos] -= 1;
20426 istrigged = false;
20427 }
20428 }
20429 else //Unsolved version
20430 {
20431 if(alltrig || trigged) //Light
20432 curlayer->data[pos] += 1;
20433 else istrigged = false;
20434 }
20435 }
20436
1/2
✓ Branch 0 taken 4470488176 times.
✗ Branch 1 not taken.
4470488176 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20437 {
20438 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20439 bool trigged = (istrig[pos]&trigflag);
20440 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20441 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20442 {
20443 do_trigger_combo(layer, pos);
20444 }
20445 }
20446 4470488176 }
20447 25400501 }
20448
1/2
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
3628643 word c = tmpscr->numFFC();
20449
2/2
✓ Branch 0 taken 3628643 times.
✓ Branch 1 taken 112291528 times.
115920171 for(word i=0; i<c; i++)
20450 {
20451 112291528 ffcdata& ffc = tmpscr->ffcs[i];
20452
1/2
✓ Branch 0 taken 112291528 times.
✗ Branch 1 not taken.
112291528 newcombo const* cmb = &combobuf[ffc.getData()];
20453
7/14
✓ Branch 0 taken 112291528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112291528 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112291528 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 112291528 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 112291528 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 112291528 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 112291528 times.
✗ Branch 13 not taken.
112291528 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
20454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112291528 times.
112291528 if(cmb->type == cLIGHTTARGET)
20455 {
20456 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20457 hastrigs = true;
20458 bool trigged = (istrig[pos]&trigflag);
20459 if(cmb->usrflags&cflag2) //Invert
20460 trigged = !trigged;
20461 if(cmb->usrflags&cflag1) //Solved Version
20462 {
20463 if(!(alltrig || trigged)) //Revert
20464 {
20465 ffc.incData(-1);
20466 istrigged = false;
20467 }
20468 }
20469 else //Unsolved version
20470 {
20471 if(alltrig || trigged) //Light
20472 ffc.incData(1);
20473 else istrigged = false;
20474 }
20475 }
20476
1/2
✓ Branch 0 taken 112291528 times.
✗ Branch 1 not taken.
112291528 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20477 {
20478 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20479 bool trigged = (istrig[pos]&trigflag);
20480 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20481 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20482 {
20483 do_trigger_combo_ffc(i);
20484 }
20485 }
20486 112291528 }
20487
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3628643 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3628643 if(hastrigs && istrigged && !alltrig)
20488 {
20489 hidden_entrance(0,true,false,-7);
20490 sfx(tmpscr->secretsfx);
20491 if(!(tmpscr->flags5&fTEMPSECRETS))
20492 {
20493 setmapflag(mSECRET);
20494 setmapflag(mLIGHTBEAM);
20495 }
20496 }
20497 3628643 }
20498
20499 3625005 void HeroClass::checktouchblk()
20500 {
20501
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3611599 times.
3625005 if(toogam) return;
20502
20503
2/2
✓ Branch 0 taken 191087 times.
✓ Branch 1 taken 3420512 times.
3611599 if(!pushing)
20504 3420512 return;
20505
20506 191087 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
20507
20508
4/4
✓ Branch 0 taken 190907 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 190811 times.
191087 if(charging > 0 || spins > 0) //if not I probably will at some point...
20509 {
20510
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 if(Up()&&Left())tdir = (charging%2)*2;
20511
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 else if(Up()&&Right())tdir = (charging%2)*3;
20512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Left())tdir = 1+(charging%2)*1;
20513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Right())tdir = 1+(charging%2)*2;
20514 else
20515 {
20516
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if(Up())tdir=0;
20517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(Down())tdir=1;
20518
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(Left())tdir=2;
20519 else if(Right())tdir=3;
20520 }
20521 276 }
20522
20523 191087 int32_t tx=0,ty=-1;
20524
20525
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 57570 times.
✓ Branch 2 taken 46907 times.
✓ Branch 3 taken 40321 times.
✓ Branch 4 taken 46289 times.
191087 switch(tdir)
20526 {
20527 case up:
20528
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 57530 times.
57570 if(touchcombo(x,y+(bigHitbox?0:7)))
20529 {
20530 40 tx=x;
20531 40 ty=y+(bigHitbox?0:7);
20532 40 }
20533
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 57509 times.
57530 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
20534 {
20535 21 tx=x+8;
20536 21 ty=y+(bigHitbox?0:7);
20537 21 }
20538
20539 57570 break;
20540
20541 case down:
20542
2/2
✓ Branch 0 taken 1253 times.
✓ Branch 1 taken 45654 times.
46907 if(touchcombo(x,y+16))
20543 {
20544 1253 tx=x;
20545 1253 ty=y+16;
20546 1253 }
20547
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 45417 times.
45654 else if(touchcombo(x+8,y+16))
20548 {
20549 237 tx=x+8;
20550 237 ty=y+16;
20551 237 }
20552
20553 46907 break;
20554
20555 case left:
20556
2/2
✓ Branch 0 taken 39760 times.
✓ Branch 1 taken 561 times.
40321 if(touchcombo(x-1,y+15))
20557 {
20558 561 tx=x-1;
20559 561 ty=y+15;
20560 561 }
20561
20562 40321 break;
20563
20564 case right:
20565
2/2
✓ Branch 0 taken 45300 times.
✓ Branch 1 taken 989 times.
46289 if(touchcombo(x+16,y+15))
20566 {
20567 989 tx=x+16;
20568 989 ty=y+15;
20569 989 }
20570
20571 46289 break;
20572 }
20573
20574
2/2
✓ Branch 0 taken 187986 times.
✓ Branch 1 taken 3101 times.
191087 if(ty>=0)
20575 {
20576 3101 ty&=0xF0;
20577 3101 tx&=0xF0;
20578 3101 int32_t di = ty+(tx>>4);
20579
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3101 if((getAction() != hopping || isSideViewHero()))
20580 {
20581 3101 trigger_armos_grave(0, di, dir);
20582 3101 }
20583 3101 }
20584 3625005 }
20585
20586 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
20587 {
20588 switch(cdir)
20589 {
20590 case up:
20591 cy-=16;
20592 break;
20593
20594 case down:
20595 cy+=16;
20596 break;
20597
20598 case left:
20599 cx-=16;
20600 break;
20601
20602 case right:
20603 cx+=16;
20604 break;
20605 }
20606
20607 // off the screen
20608 if(cx<0 || cy<0 || cx>255 || cy>175)
20609 {
20610 int32_t ns = nextscr(cdir);
20611
20612 if(ns==0xFFFF) return 0;
20613
20614 // want actual screen index, not game->maps[] index
20615 ns = (ns&127) + (ns>>7)*MAPSCRS;
20616
20617 switch(cdir)
20618 {
20619 case up:
20620 cy=160;
20621 break;
20622
20623 case down:
20624 cy=0;
20625 break;
20626
20627 case left:
20628 cx=240;
20629 break;
20630
20631 case right:
20632 cx=0;
20633 break;
20634 }
20635
20636 // from MAPCOMBO()
20637 int32_t cmb = (cy&0xF0)+(cx>>4);
20638
20639 if(cmb>175)
20640 return 0;
20641
20642 return TheMaps[ns].data[cmb]; // entire combo code
20643 }
20644
20645 return MAPCOMBO(cx,cy);
20646 }
20647
20648 2361 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
20649 {
20650
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 658 times.
✓ Branch 4 taken 676 times.
2361 switch(cdir)
20651 {
20652 case up:
20653 560 cy-=16;
20654 560 break;
20655
20656 case down:
20657 467 cy+=16;
20658 467 break;
20659
20660 case left:
20661 658 cx-=16;
20662 658 break;
20663
20664 case right:
20665 676 cx+=16;
20666 676 break;
20667 }
20668
20669 // off the screen
20670
8/8
✓ Branch 0 taken 2339 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 2308 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 2283 times.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 2267 times.
2361 if(cx<0 || cy<0 || cx>255 || cy>175)
20671 {
20672 94 int32_t ns = nextscr(cdir);
20673
20674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(ns==0xFFFF) return 0;
20675
20676 // want actual screen index, not game->maps[] index
20677 94 ns = (ns&127) + (ns>>7)*MAPSCRS;
20678
20679
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 25 times.
94 switch(cdir)
20680 {
20681 case up:
20682 31 cy=160;
20683 31 break;
20684
20685 case down:
20686 16 cy=0;
20687 16 break;
20688
20689 case left:
20690 22 cx=240;
20691 22 break;
20692
20693 case right:
20694 25 cx=0;
20695 25 break;
20696 }
20697
20698 // from MAPCOMBO()
20699 94 int32_t cmb = (cy&0xF0)+(cx>>4);
20700
20701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(cmb>175)
20702 return 0;
20703
20704
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 87 times.
94 if(!comboflag)
20705 {
20706 87 return TheMaps[ns].sflag[cmb]; // flag
20707 }
20708 else
20709 {
20710 7 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
20711 }
20712 }
20713
20714
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 1726 times.
2267 if(comboflag)
20715 {
20716 541 return MAPCOMBOFLAG(cx,cy);
20717 }
20718
20719 1726 return MAPFLAG(cx,cy);
20720 2361 }
20721
20722 bool did_secret;
20723
20724 3625005 void HeroClass::checkspecial()
20725 {
20726 3625005 checktouchblk();
20727
20728 3625005 bool hasmainguy = hasMainGuy(); // calculate it once
20729
20730
4/4
✓ Branch 0 taken 3584114 times.
✓ Branch 1 taken 40891 times.
✓ Branch 2 taken 2582978 times.
✓ Branch 3 taken 1001136 times.
3625005 if(!(loaded_enemies && !hasmainguy))
20731 2623869 did_secret=false;
20732 else
20733 {
20734 // after beating enemies
20735
20736 // item
20737
2/2
✓ Branch 0 taken 1000820 times.
✓ Branch 1 taken 316 times.
1001136 if(hasitem&(4|2|1))
20738 {
20739 316 int32_t Item=tmpscr->item;
20740
20741 //if(getmapflag())
20742 // Item=0;
20743
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 316 times.
316 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20744 {
20745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if(hasitem==1)
20746 316 sfx(WAV_CLEARED);
20747
20748
2/4
✓ Branch 0 taken 316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
✗ Branch 3 not taken.
632 items.add(new item((zfix)tmpscr->itemx,
20749
6/12
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 316 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 316 times.
✗ Branch 11 not taken.
316 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20750
6/10
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 290 times.
✗ Branch 9 not taken.
316 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20752 316 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20753 316 }
20754
20755 316 hasitem &= ~ (4|2|1);
20756 316 }
20757
20758 // generic 'Enemies->' trigger
20759
2/2
✓ Branch 0 taken 7007952 times.
✓ Branch 1 taken 1001136 times.
8009088 for(auto lyr = 0; lyr < 7; ++lyr)
20760 {
20761
2/2
✓ Branch 0 taken 1233399552 times.
✓ Branch 1 taken 7007952 times.
1240407504 for(auto pos = 0; pos < 176; ++pos)
20762 {
20763 1233399552 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
20764
1/2
✓ Branch 0 taken 1233399552 times.
✗ Branch 1 not taken.
1233399552 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20765 {
20766 do_trigger_combo(lyr,pos);
20767 }
20768 1233399552 }
20769 7007952 }
20770 1001136 word c = tmpscr->numFFC();
20771
2/2
✓ Branch 0 taken 29377887 times.
✓ Branch 1 taken 1001136 times.
30379023 for(word i=0; i<c; i++)
20772 {
20773 29377887 ffcdata& ffc = tmpscr->ffcs[i];
20774 29377887 newcombo const& cmb = combobuf[ffc.getData()];
20775
1/2
✓ Branch 0 taken 29377887 times.
✗ Branch 1 not taken.
29377887 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20776 {
20777 do_trigger_combo_ffc(i);
20778 }
20779 29377887 }
20780
1/2
✓ Branch 0 taken 1001136 times.
✗ Branch 1 not taken.
1001136 if(tmpscr->flags9 & fENEMY_WAVES)
20781 {
20782 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
20783 }
20784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1001136 times.
1001136 if(!hasmainguy)
20785 {
20786 // if room has traps, guys don't come back
20787
2/2
✓ Branch 0 taken 512581632 times.
✓ Branch 1 taken 1001136 times.
513582768 for(int32_t i=0; i<eMAXGUYS; i++)
20788 {
20789
4/4
✓ Branch 0 taken 14758442 times.
✓ Branch 1 taken 497823190 times.
✓ Branch 2 taken 1945670 times.
✓ Branch 3 taken 12812772 times.
512581632 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
20790
4/4
✓ Branch 0 taken 5515 times.
✓ Branch 1 taken 1940155 times.
✓ Branch 2 taken 5513 times.
✓ Branch 3 taken 2 times.
1945672 if(guys.idCount(i) && !getmapflag(mTMPNORET))
20791 2 setmapflag(mTMPNORET);
20792 512581632 }
20793 // clear enemies and open secret
20794
4/4
✓ Branch 0 taken 890615 times.
✓ Branch 1 taken 110521 times.
✓ Branch 2 taken 890197 times.
✓ Branch 3 taken 418 times.
1001136 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
20795 {
20796 418 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
20797 418 hidden_entrance(0,true,only16_31,-2);
20798
20799
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 394 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 19 times.
418 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
20800 {
20801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
20802 19 }
20803
20804 418 sfx(tmpscr->secretsfx);
20805 418 did_secret=true;
20806 418 }
20807 1001136 }
20808 }
20809
20810 // doors
20811
2/2
✓ Branch 0 taken 2614735 times.
✓ Branch 1 taken 12727441 times.
15342176 for(int32_t i=0; i<4; i++)
20812
2/2
✓ Branch 0 taken 11717171 times.
✓ Branch 1 taken 1010270 times.
12727441 if(tmpscr->door[i]==dSHUTTER)
20813 {
20814
4/4
✓ Branch 0 taken 994446 times.
✓ Branch 1 taken 15824 times.
✓ Branch 2 taken 567 times.
✓ Branch 3 taken 993879 times.
1010270 if(opendoors==0 && loaded_enemies)
20815 {
20816
4/4
✓ Branch 0 taken 871594 times.
✓ Branch 1 taken 122285 times.
✓ Branch 2 taken 870599 times.
✓ Branch 3 taken 995 times.
993879 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
20817 995 opendoors=12;
20818 993879 }
20819
2/2
✓ Branch 0 taken 13095 times.
✓ Branch 1 taken 3296 times.
16391 else if(opendoors<0)
20820 3296 ++opendoors;
20821
2/2
✓ Branch 0 taken 12026 times.
✓ Branch 1 taken 1069 times.
13095 else if((--opendoors)==0)
20822 1069 openshutters();
20823
20824 1010270 break;
20825 }
20826
20827 // set boss flag when boss is gone
20828
6/6
✓ Branch 0 taken 3584114 times.
✓ Branch 1 taken 40891 times.
✓ Branch 2 taken 58135 times.
✓ Branch 3 taken 3525979 times.
✓ Branch 4 taken 46515 times.
✓ Branch 5 taken 11620 times.
3625005 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
20829 {
20830 11620 game->lvlitems[dlevel]|=liBOSS;
20831 11620 stop_sfx(tmpscr->bosssfx);
20832 11620 }
20833
20834
2/2
✓ Branch 0 taken 3612489 times.
✓ Branch 1 taken 12516 times.
3625005 if(getmapflag(mCHEST)) // if special stuff done before
20835 {
20836 12516 remove_chests((currscr>=128)?1:0);
20837 12516 }
20838
20839
1/2
✓ Branch 0 taken 3625005 times.
✗ Branch 1 not taken.
3625005 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
20840 {
20841 remove_lockedchests((currscr>=128)?1:0);
20842 }
20843
20844
1/2
✓ Branch 0 taken 3625005 times.
✗ Branch 1 not taken.
3625005 if(getmapflag(mBOSSCHEST)) // if special stuff done before
20845 {
20846 remove_bosschests((currscr>=128)?1:0);
20847 }
20848
20849 3625005 clear_xstatecombos((currscr>=128)?1:0);
20850
20851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3625005 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3625005 if((hasitem&8) && triggered_screen_secrets)
20852 {
20853 int32_t Item=tmpscr->item;
20854
20855 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20856 {
20857 items.add(new item((zfix)tmpscr->itemx,
20858 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20859 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20860 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20861 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20862 }
20863
20864 hasitem &= ~8;
20865 }
20866 3625005 }
20867
20868 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
20869 2528792 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
20870 {
20871 int32_t tmp;
20872 2528792 poses[0] = COMBOPOS(x1,y1);
20873
20874 2528792 tmp = COMBOPOS(x1,y2);
20875
2/2
✓ Branch 0 taken 1944455 times.
✓ Branch 1 taken 584337 times.
2528792 if(tmp == poses[0])
20876 1944455 poses[1] = -1;
20877 584337 else poses[1] = tmp;
20878
20879 2528792 tmp = COMBOPOS(x2,y1);
20880
3/4
✓ Branch 0 taken 1142349 times.
✓ Branch 1 taken 1386443 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1142349 times.
2528792 if(tmp == poses[0] || tmp == poses[1])
20881 1386443 poses[2] = -1;
20882 1142349 else poses[2] = tmp;
20883
20884 2528792 tmp = COMBOPOS(x2,y2);
20885
6/6
✓ Branch 0 taken 1473656 times.
✓ Branch 1 taken 1055136 times.
✓ Branch 2 taken 1142349 times.
✓ Branch 3 taken 331307 times.
✓ Branch 4 taken 889319 times.
✓ Branch 5 taken 253030 times.
2528792 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
20886 2275762 poses[3] = -1;
20887 253030 else poses[3] = tmp;
20888 2528792 }
20889
20890 3624409 void HeroClass::checkspecial2(int32_t *ls)
20891 {
20892
4/6
✓ Branch 0 taken 3119385 times.
✓ Branch 1 taken 505024 times.
✓ Branch 2 taken 3119385 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3119385 times.
3624409 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
20893 {
20894
2/2
✓ Branch 0 taken 924630 times.
✓ Branch 1 taken 2194755 times.
3119385 if(y.getInt()&7)
20895 924630 return;
20896
20897
2/2
✓ Branch 0 taken 1273403 times.
✓ Branch 1 taken 921352 times.
2194755 if(x.getInt()&7)
20898 1273403 return;
20899 921352 }
20900
20901
2/2
✓ Branch 0 taken 4512 times.
✓ Branch 1 taken 1421864 times.
1426376 if(toogam) return;
20902
20903 1421864 bool didstrig = false;
20904
20905
2/2
✓ Branch 0 taken 2843393 times.
✓ Branch 1 taken 1421861 times.
4265254 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
20906 {
20907
4/4
✓ Branch 0 taken 5686786 times.
✓ Branch 1 taken 2843390 times.
✓ Branch 2 taken 11373569 times.
✓ Branch 3 taken 5686783 times.
19903742 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
20908 {
20909
2/2
✓ Branch 0 taken 5686783 times.
✓ Branch 1 taken 5686786 times.
11373569 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
20910 11373569 int32_t stype = cmb.type;
20911 11373569 int32_t warpsound = cmb.attribytes[0];
20912
1/2
✓ Branch 0 taken 11373569 times.
✗ Branch 1 not taken.
11373569 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
20913 stype = cNONE;
20914
2/2
✓ Branch 0 taken 11373566 times.
✓ Branch 1 taken 3 times.
11373569 if(stype==cSWARPA)
20915 {
20916
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(tmpscr->flags5&fDIRECTSWARP)
20917 {
20918 didpit=true;
20919 pitx=x;
20920 pity=y;
20921 }
20922
20923 3 sdir=dir;
20924 3 dowarp(0,0,warpsound);
20925 3 return;
20926 }
20927
20928
1/2
✓ Branch 0 taken 11373566 times.
✗ Branch 1 not taken.
11373566 if(stype==cSWARPB)
20929 {
20930 if(tmpscr->flags5&fDIRECTSWARP)
20931 {
20932 didpit=true;
20933 pitx=x;
20934 pity=y;
20935 }
20936
20937 sdir=dir;
20938 dowarp(0,1,warpsound);
20939 return;
20940 }
20941
20942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11373566 times.
11373566 if(stype==cSWARPC)
20943 {
20944 if(tmpscr->flags5&fDIRECTSWARP)
20945 {
20946 didpit=true;
20947 pitx=x;
20948 pity=y;
20949 }
20950
20951 sdir=dir;
20952 dowarp(0,2,warpsound);
20953 return;
20954 }
20955
20956
1/2
✓ Branch 0 taken 11373566 times.
✗ Branch 1 not taken.
11373566 if(stype==cSWARPD)
20957 {
20958 if(tmpscr->flags5&fDIRECTSWARP)
20959 {
20960 didpit=true;
20961 pitx=x;
20962 pity=y;
20963 }
20964
20965 sdir=dir;
20966 dowarp(0,3,warpsound);
20967 return;
20968 }
20969
20970
1/2
✓ Branch 0 taken 11373566 times.
✗ Branch 1 not taken.
11373566 if(stype==cSWARPR)
20971 {
20972 if(tmpscr->flags5&fDIRECTSWARP)
20973 {
20974 didpit=true;
20975 pitx=x;
20976 pity=y;
20977 }
20978
20979 sdir=dir;
20980 dowarp(0,(zc_oldrand()%4),warpsound);
20981 return;
20982 }
20983
20984 11373566 int32_t pos = COMBOPOS(x+j, y+i);
20985
4/4
✓ Branch 0 taken 11371410 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 11372856 times.
✓ Branch 3 taken 710 times.
11373566 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
20986 {
20987 // zprint("Step Secs\n");
20988
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710 if(stype==cSTRIGFLAG && canPermSecret())
20989 {
20990 if(!didstrig)
20991 {
20992 stepsecret = pos;
20993
20994 if(!(tmpscr->flags5&fTEMPSECRETS))
20995 {
20996 setmapflag(mSECRET);
20997 }
20998 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
20999 //zprint("Step Secrets SFX: %d\n", thesfx);
21000 sfx(warpsound,pan((int32_t)x));
21001 hidden_entrance(0,true,false);
21002 didstrig = true;
21003 }
21004 }
21005 else
21006 {
21007
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 345 times.
710 if(!didstrig)
21008 {
21009 345 stepsecret = pos;
21010 345 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21011 345 hidden_entrance(0,true,only16_31);
21012 345 didstrig = true;
21013 //play trigger sound
21014 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21015 //zprint("Step Secrets SFX: %d\n", thesfx);
21016 //sfx(thesfx,pan((int32_t)x));
21017 345 sfx(warpsound,pan((int32_t)x));
21018 345 }
21019 }
21020 710 }
21021 17060349 }
21022 2843390 }
21023
21024 1421861 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
21025
21026 // check if he's standing on a warp he just came out of
21027 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
21028
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1421695 times.
1421861 if (!get_bit(quest_rules,qr_210_WARPRETURN))
21029 {
21030
6/6
✓ Branch 0 taken 1420467 times.
✓ Branch 1 taken 1228 times.
✓ Branch 2 taken 161765 times.
✓ Branch 3 taken 1258702 times.
✓ Branch 4 taken 14514 times.
✓ Branch 5 taken 147251 times.
1421695 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
21031 {
21032
5/6
✓ Branch 0 taken 146637 times.
✓ Branch 1 taken 614 times.
✓ Branch 2 taken 145666 times.
✓ Branch 3 taken 971 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 145666 times.
147251 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
21033 {
21034
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 145661 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
145666 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21035 145666 else return;
21036 }
21037 1585 }
21038 1276029 }
21039 else
21040 {
21041
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if((int(y)&0xF8)==warpy)
21042 {
21043 if(x==warpx)
21044 {
21045 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21046 else return;
21047 }
21048 }
21049 }
21050
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1276029 times.
1276195 if (!RaftPass) warpy=-1;
21051
21052
6/6
✓ Branch 0 taken 1274055 times.
✓ Branch 1 taken 1808 times.
✓ Branch 2 taken 56819 times.
✓ Branch 3 taken 1217236 times.
✓ Branch 4 taken 42139 times.
✓ Branch 5 taken 14680 times.
1276195 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
21053 {
21054 1233724 raftwarpy = -1;
21055 1233724 }
21056
6/6
✓ Branch 0 taken 1274606 times.
✓ Branch 1 taken 1257 times.
✓ Branch 2 taken 64355 times.
✓ Branch 3 taken 1210251 times.
✓ Branch 4 taken 47345 times.
✓ Branch 5 taken 17010 times.
1275863 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
21057 {
21058 1228518 raftwarpx = -1;
21059 1228518 }
21060 1275863 int32_t tx=x;
21061 1275863 int32_t ty=y;
21062
21063 1275863 int32_t flag=0;
21064 1275863 int32_t flag2=0;
21065 1275863 int32_t flag3=0;
21066 1275863 int32_t type=0;
21067 1275863 int32_t water=0;
21068 1275863 int32_t index = 0;
21069
21070 1275863 bool setsave=false;
21071 1275863 int32_t warpsfx2 = 0;
21072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275863 times.
1275863 if (RaftPass) goto RaftingStuff;
21073
21074 //bool gotpit=false;
21075
21076 int32_t x1,x2,y1,y2;
21077 1275863 x1 = tx;
21078 1275863 x2 = tx+15;
21079 1275863 y1 = ty;
21080 1275863 y2 = ty+15;
21081
21082
4/4
✓ Branch 0 taken 791392 times.
✓ Branch 1 taken 484471 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 791558 times.
1275863 if((diagonalMovement||NO_GRIDLOCK))
21083 {
21084 484637 x1 = tx+4;
21085 484637 x2 = tx+11;
21086 484637 y1 = ty+4;
21087 484637 y2 = ty+11;
21088 484637 }
21089
21090 int32_t types[4];
21091 1276195 types[0]=types[1]=types[2]=types[3]=-1;
21092 int32_t cids[4];
21093 int32_t ffcids[4];
21094 1276195 cids[0]=cids[1]=cids[2]=cids[3]=-1;
21095 1276195 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
21096 //
21097 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
21098 //
21099 1276195 types[0] = MAPFLAG(x1,y1);
21100 1276195 types[1] = MAPFLAG(x1,y2);
21101 1276195 types[2] = MAPFLAG(x2,y1);
21102 1276195 types[3] = MAPFLAG(x2,y2);
21103
21104
21105 //MAPFFCOMBO
21106
21107
21108
6/6
✓ Branch 0 taken 1244323 times.
✓ Branch 1 taken 31872 times.
✓ Branch 2 taken 1240138 times.
✓ Branch 3 taken 4185 times.
✓ Branch 4 taken 12449 times.
✓ Branch 5 taken 1227689 times.
1276195 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21109 1227689 flag = types[0];
21110
21111 // 2.10 compatibility...
21112
8/10
✓ Branch 0 taken 31279 times.
✓ Branch 1 taken 17227 times.
✓ Branch 2 taken 26699 times.
✓ Branch 3 taken 4580 times.
✓ Branch 4 taken 17362 times.
✓ Branch 5 taken 9337 times.
✓ Branch 6 taken 17362 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 17362 times.
48506 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
21113 9337 flag = types[0];
21114
21115
21116 1276195 types[0] = MAPCOMBOFLAG(x1,y1);
21117 1276195 types[1] = MAPCOMBOFLAG(x1,y2);
21118 1276195 types[2] = MAPCOMBOFLAG(x2,y1);
21119 1276195 types[3] = MAPCOMBOFLAG(x2,y2);
21120
21121
6/6
✓ Branch 0 taken 1274494 times.
✓ Branch 1 taken 1701 times.
✓ Branch 2 taken 1274145 times.
✓ Branch 3 taken 349 times.
✓ Branch 4 taken 472 times.
✓ Branch 5 taken 1273673 times.
1276195 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21122 1273673 flag2 = types[0];
21123
21124 1276195 types[0] = MAPFFCOMBOFLAG(x1,y1);
21125 1276195 types[1] = MAPFFCOMBOFLAG(x1,y2);
21126 1276195 types[2] = MAPFFCOMBOFLAG(x2,y1);
21127 1276195 types[3] = MAPFFCOMBOFLAG(x2,y2);
21128
21129
21130 //
21131
21132
6/6
✓ Branch 0 taken 1276023 times.
✓ Branch 1 taken 172 times.
✓ Branch 2 taken 1276013 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1276010 times.
1276195 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21133 1276010 flag3 = types[0];
21134
21135 //
21136 // Now, let's check for warp combos...
21137 //
21138
21139 //
21140
21141 1276195 cids[0] = MAPCOMBO(x1,y1);
21142 1276195 cids[1] = MAPCOMBO(x1,y2);
21143 1276195 cids[2] = MAPCOMBO(x2,y1);
21144 1276195 cids[3] = MAPCOMBO(x2,y2);
21145
21146 1276195 types[0] = COMBOTYPE(x1,y1);
21147
21148
2/2
✓ Branch 0 taken 1254743 times.
✓ Branch 1 taken 21452 times.
1276195 if(MAPFFCOMBO(x1,y1))
21149 {
21150 21452 types[0] = FFCOMBOTYPE(x1,y1);
21151 21452 cids[0] = MAPFFCOMBO(x1,y1);
21152 21452 }
21153
21154 1276195 types[1] = COMBOTYPE(x1,y2);
21155
21156
2/2
✓ Branch 0 taken 1260385 times.
✓ Branch 1 taken 15810 times.
1276195 if(MAPFFCOMBO(x1,y2))
21157 {
21158 15810 types[1] = FFCOMBOTYPE(x1,y2);
21159 15810 cids[1] = MAPFFCOMBO(x1,y2);
21160 15810 }
21161
21162 1276195 types[2] = COMBOTYPE(x2,y1);
21163
21164
2/2
✓ Branch 0 taken 1254656 times.
✓ Branch 1 taken 21539 times.
1276195 if(MAPFFCOMBO(x2,y1))
21165 {
21166 21539 types[2] = FFCOMBOTYPE(x2,y1);
21167 21539 cids[2] = MAPFFCOMBO(x2,y1);
21168 21539 }
21169 1276195 types[3] = COMBOTYPE(x2,y2);
21170
21171
2/2
✓ Branch 0 taken 1260243 times.
✓ Branch 1 taken 15952 times.
1276195 if(MAPFFCOMBO(x2,y2))
21172 {
21173 15952 types[3] = FFCOMBOTYPE(x2,y2);
21174 15952 cids[3] = MAPFFCOMBO(x2,y2);
21175 15952 }
21176 // Change B, C and D warps into A, for the comparison below...
21177
2/2
✓ Branch 0 taken 5104116 times.
✓ Branch 1 taken 1276195 times.
6380311 for(int32_t i=0; i<4; i++)
21178 {
21179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5104116 times.
5104116 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21180 {
21181 types[i] = cNONE;
21182 continue;
21183 }
21184
2/2
✓ Branch 0 taken 1598 times.
✓ Branch 1 taken 5102518 times.
5104116 if(types[i]==cCAVE)
21185 {
21186 1598 index=0;
21187 1598 warpsfx2 = combobuf[cids[i]].attribytes[0];
21188 1598 }
21189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5102518 times.
5102518 else if(types[i]==cCAVEB)
21190 {
21191 types[i]=cCAVE;
21192 index=1;
21193 warpsfx2 = combobuf[cids[i]].attribytes[0];
21194 }
21195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5102518 times.
5102518 else if(types[i]==cCAVEC)
21196 {
21197 types[i]=cCAVE;
21198 index=2;
21199 warpsfx2 = combobuf[cids[i]].attribytes[0];
21200 }
21201
1/2
✓ Branch 0 taken 5102518 times.
✗ Branch 1 not taken.
5102518 else if(types[i]==cCAVED)
21202 {
21203 types[i]=cCAVE;
21204 index=3;
21205 warpsfx2 = combobuf[cids[i]].attribytes[0];
21206 }
21207
21208
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 5103992 times.
5104116 if(types[i]==cPIT)
21209 {
21210 124 index=0;
21211 124 warpsfx2 = combobuf[cids[i]].attribytes[0];
21212 124 }
21213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103992 times.
5103992 else if(types[i]==cPITB)
21214 {
21215 types[i]=cPIT;
21216 warpsfx2 = combobuf[cids[i]].attribytes[0];
21217 index=1;
21218 }
21219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103992 times.
5103992 else if(types[i]==cPITC)
21220 {
21221 types[i]=cPIT;
21222 warpsfx2 = combobuf[cids[i]].attribytes[0];
21223 index=2;
21224 }
21225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103992 times.
5103992 else if(types[i]==cPITD)
21226 {
21227 types[i]=cPIT;
21228 warpsfx2 = combobuf[cids[i]].attribytes[0];
21229 index=3;
21230 }
21231
1/2
✓ Branch 0 taken 5103992 times.
✗ Branch 1 not taken.
5103992 else if(types[i]==cPITR)
21232 {
21233 types[i]=cPIT;
21234 warpsfx2 = combobuf[cids[i]].attribytes[0];
21235 index=zc_oldrand()%4;
21236 }
21237
21238
2/2
✓ Branch 0 taken 6596 times.
✓ Branch 1 taken 5097520 times.
5104116 if(types[i]==cSTAIR)
21239 {
21240 6596 index=0;
21241 6596 warpsfx2 = combobuf[cids[i]].attribytes[0];
21242 6596 }
21243
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5097420 times.
5097520 else if(types[i]==cSTAIRB)
21244 {
21245 100 types[i]=cSTAIR;
21246 100 warpsfx2 = combobuf[cids[i]].attribytes[0];
21247 100 index=1;
21248 100 }
21249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5097420 times.
5097420 else if(types[i]==cSTAIRC)
21250 {
21251 types[i]=cSTAIR;
21252 warpsfx2 = combobuf[cids[i]].attribytes[0];
21253 index=2;
21254 }
21255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5097420 times.
5097420 else if(types[i]==cSTAIRD)
21256 {
21257 types[i]=cSTAIR;
21258 warpsfx2 = combobuf[cids[i]].attribytes[0];
21259 index=3;
21260 }
21261
1/2
✓ Branch 0 taken 5097420 times.
✗ Branch 1 not taken.
5097420 else if(types[i]==cSTAIRR)
21262 {
21263 types[i]=cSTAIR;
21264 index=zc_oldrand()%4;
21265 warpsfx2 = combobuf[cids[i]].attribytes[0];
21266 }
21267
21268
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 5103765 times.
5104116 if(types[i]==cCAVE2)
21269 {
21270 351 index=0;
21271 351 warpsfx2 = combobuf[cids[i]].attribytes[0];
21272 351 }
21273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103765 times.
5103765 else if(types[i]==cCAVE2B)
21274 {
21275 types[i]=cCAVE2;
21276 index=1;
21277 warpsfx2 = combobuf[cids[i]].attribytes[0];
21278 }
21279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103765 times.
5103765 else if(types[i]==cCAVE2C)
21280 {
21281 types[i]=cCAVE2;
21282 warpsfx2 = combobuf[cids[i]].attribytes[0];
21283 index=2;
21284 }
21285
1/2
✓ Branch 0 taken 5103765 times.
✗ Branch 1 not taken.
5103765 else if(types[i]==cCAVE2D)
21286 {
21287 types[i]=cCAVE2;
21288 warpsfx2 = combobuf[cids[i]].attribytes[0];
21289 index=3;
21290 }
21291
21292
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 5104075 times.
5104116 if(types[i]==cSWIMWARP)
21293 {
21294 41 index=0;
21295 41 warpsfx2 = combobuf[cids[i]].attribytes[0];
21296 41 }
21297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5104075 times.
5104075 else if(types[i]==cSWIMWARPB)
21298 {
21299 types[i]=cSWIMWARP;
21300 warpsfx2 = combobuf[cids[i]].attribytes[0];
21301 index=1;
21302 }
21303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5104075 times.
5104075 else if(types[i]==cSWIMWARPC)
21304 {
21305 types[i]=cSWIMWARP;
21306 warpsfx2 = combobuf[cids[i]].attribytes[0];
21307 index=2;
21308 }
21309
1/2
✓ Branch 0 taken 5104075 times.
✗ Branch 1 not taken.
5104075 else if(types[i]==cSWIMWARPD)
21310 {
21311 types[i]=cSWIMWARP;
21312 warpsfx2 = combobuf[cids[i]].attribytes[0];
21313 index=3;
21314 }
21315
21316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5104116 times.
5104116 if(types[i]==cDIVEWARP)
21317 {
21318 index=0;
21319 warpsfx2 = combobuf[cids[i]].attribytes[0];
21320 }
21321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5104116 times.
5104116 else if(types[i]==cDIVEWARPB)
21322 {
21323 types[i]=cDIVEWARP;
21324 warpsfx2 = combobuf[cids[i]].attribytes[0];
21325 index=1;
21326 }
21327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5104116 times.
5104116 else if(types[i]==cDIVEWARPC)
21328 {
21329 types[i]=cDIVEWARP;
21330 warpsfx2 = combobuf[cids[i]].attribytes[0];
21331 index=2;
21332 }
21333
1/2
✓ Branch 0 taken 5104116 times.
✗ Branch 1 not taken.
5104116 else if(types[i]==cDIVEWARPD)
21334 {
21335 types[i]=cDIVEWARP;
21336 warpsfx2 = combobuf[cids[i]].attribytes[0];
21337 index=3;
21338 }
21339
21340
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 5103426 times.
5104116 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
21341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103426 times.
5103426 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
21342
2/2
✓ Branch 0 taken 5103410 times.
✓ Branch 1 taken 16 times.
5103426 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
21343 5104116 }
21344
21345 // Special case for step combos; otherwise, they act oddly in some cases
21346
8/8
✓ Branch 0 taken 1184963 times.
✓ Branch 1 taken 91232 times.
✓ Branch 2 taken 1173219 times.
✓ Branch 3 taken 11744 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 102893 times.
✓ Branch 6 taken 15743 times.
✓ Branch 7 taken 15660 times.
1276195 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
21347 {
21348
7/8
✓ Branch 0 taken 1147220 times.
✓ Branch 1 taken 10256 times.
✓ Branch 2 taken 1147220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 1146968 times.
✓ Branch 6 taken 81 times.
✓ Branch 7 taken 171 times.
1188962 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21349 1147139 type = types[1];
21350 1157476 }
21351
21352 //Generic Step
21353
7/8
✓ Branch 0 taken 1264478 times.
✓ Branch 1 taken 11551 times.
✓ Branch 2 taken 1264478 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 253 times.
✓ Branch 5 taken 1264225 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 171 times.
1276029 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21354 {
21355 int32_t poses[4];
21356 int32_t sensPoses[4];
21357 1264396 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
21358 1264396 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
21359
3/4
✓ Branch 0 taken 780441 times.
✓ Branch 1 taken 483955 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780441 times.
1264396 if(diagonalMovement||NO_GRIDLOCK)
21360 483955 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
21361 780441 else getPoses(poses, tx, ty, tx+15, ty+15);
21362 1264396 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
21363 1264396 bool hasStep[4] = {false};
21364
2/2
✓ Branch 0 taken 5057584 times.
✓ Branch 1 taken 1264396 times.
6321980 for(auto p = 0; p < 4; ++p)
21365 {
21366
2/2
✓ Branch 0 taken 5056878 times.
✓ Branch 1 taken 35398852 times.
40455730 for(auto lyr = 0; lyr < 7; ++lyr)
21367 {
21368
2/2
✓ Branch 0 taken 16606060 times.
✓ Branch 1 taken 18792792 times.
35398852 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21369
4/4
✓ Branch 0 taken 16606060 times.
✓ Branch 1 taken 18792792 times.
✓ Branch 2 taken 706 times.
✓ Branch 3 taken 35398146 times.
35398852 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
21370 35398852 || types[p] == cSTEP)
21371 {
21372 706 hasStep[p] = true;
21373 706 break;
21374 }
21375 35398146 }
21376 5057584 }
21377 1264396 bool canNormalStep = true;
21378
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 1264708 times.
1264795 for(auto p = 0; p < 4; ++p)
21379 {
21380
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 1264506 times.
1264708 if(poses[p] < 0) continue;
21381
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 1264309 times.
1264506 if(!hasStep[p])
21382 {
21383 1264309 canNormalStep = false;
21384 1264309 break;
21385 }
21386 197 }
21387
2/2
✓ Branch 0 taken 5057584 times.
✓ Branch 1 taken 1264396 times.
6321980 for(auto p = 0; p < 4; ++p)
21388 {
21389
2/2
✓ Branch 0 taken 35403088 times.
✓ Branch 1 taken 5057584 times.
40460672 for(auto lyr = 0; lyr < 7; ++lyr)
21390 {
21391
2/2
✓ Branch 0 taken 16608382 times.
✓ Branch 1 taken 18794706 times.
35403088 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21392
2/2
✓ Branch 0 taken 14951174 times.
✓ Branch 1 taken 20451914 times.
35403088 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
21393
5/6
✓ Branch 0 taken 2436 times.
✓ Branch 1 taken 35400652 times.
✓ Branch 2 taken 1064 times.
✓ Branch 3 taken 1372 times.
✓ Branch 4 taken 1064 times.
✗ Branch 5 not taken.
35403088 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
21394 {
21395 do_trigger_combo(lyr,poses[p]);
21396 if(poses[p] == sensPoses[p]) continue;
21397 }
21398
3/4
✓ Branch 0 taken 14951174 times.
✓ Branch 1 taken 20451914 times.
✓ Branch 2 taken 14951174 times.
✗ Branch 3 not taken.
35403088 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
21399 {
21400 do_trigger_combo(lyr,sensPoses[p]);
21401 }
21402 35403088 }
21403 5057584 }
21404 1264396 word c = tmpscr->numFFC();
21405
2/2
✓ Branch 0 taken 36763466 times.
✓ Branch 1 taken 1264396 times.
38027862 for(word i=0; i<c; i++)
21406 {
21407 36763466 bool found = false;
21408
2/2
✓ Branch 0 taken 73526932 times.
✓ Branch 1 taken 36763466 times.
110290398 for(auto xch = 0; xch < 2; ++xch)
21409 {
21410
2/2
✓ Branch 0 taken 147053864 times.
✓ Branch 1 taken 73526932 times.
220580796 for(auto ych = 0; ych < 2; ++ych)
21411 {
21412
2/2
✓ Branch 0 taken 146976412 times.
✓ Branch 1 taken 77452 times.
147053864 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
21413 {
21414 77452 found = true;
21415 77452 }
21416 147053864 }
21417 73526932 }
21418
2/2
✓ Branch 0 taken 36732845 times.
✓ Branch 1 taken 30621 times.
36763466 if (found)
21419 {
21420 30621 ffcdata& ffc = tmpscr->ffcs[i];
21421 30621 newcombo const* cmb = &combobuf[ffc.getData()];
21422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30621 times.
30621 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
21423 {
21424 do_trigger_combo_ffc(i);
21425 }
21426 30621 }
21427 36763466 }
21428 1264396 }
21429
21430 //
21431 // Now, let's check for Save combos...
21432 //
21433 1276029 x1 = tx+4;
21434 1276029 x2 = tx+11;
21435 1276029 y1 = ty+4;
21436 1276029 y2 = ty+11;
21437
21438 1276029 types[0] = COMBOTYPE(x1,y1);
21439 1276029 cids[0] = MAPCOMBO(x1,y1);
21440
21441
2/2
✓ Branch 0 taken 1254600 times.
✓ Branch 1 taken 21429 times.
1276029 if(MAPFFCOMBO(x1,y1))
21442 {
21443 21429 types[0] = FFCOMBOTYPE(x1,y1);
21444 21429 cids[0] = MAPFFCOMBO(x1,y1);
21445 21429 }
21446
21447 1276029 types[1] = COMBOTYPE(x1,y2);
21448 1276029 cids[1] = MAPCOMBO(x1,y2);
21449
21450
2/2
✓ Branch 0 taken 1260205 times.
✓ Branch 1 taken 15824 times.
1276029 if(MAPFFCOMBO(x1,y2))
21451 {
21452 15824 types[1] = FFCOMBOTYPE(x1,y2);
21453 15824 cids[1] = MAPFFCOMBO(x1,y2);
21454 15824 }
21455
21456 1276029 types[2] = COMBOTYPE(x2,y1);
21457 1276029 cids[2] = MAPCOMBO(x2,y1);
21458
21459
2/2
✓ Branch 0 taken 1254505 times.
✓ Branch 1 taken 21524 times.
1276029 if(MAPFFCOMBO(x2,y1))
21460 {
21461 21524 types[2] = FFCOMBOTYPE(x2,y1);
21462 21524 cids[2] = MAPFFCOMBO(x2,y1);
21463 21524 }
21464
21465 1276029 types[3] = COMBOTYPE(x2,y2);
21466 1276029 cids[3] = MAPCOMBO(x2,y2);
21467
21468
2/2
✓ Branch 0 taken 1260062 times.
✓ Branch 1 taken 15967 times.
1276029 if(MAPFFCOMBO(x2,y2))
21469 {
21470 15967 types[3] = FFCOMBOTYPE(x2,y2);
21471 15967 cids[3] = MAPFFCOMBO(x2,y2);
21472 15967 }
21473
21474
21475
2/2
✓ Branch 0 taken 1276029 times.
✓ Branch 1 taken 5104116 times.
6380145 for(int32_t i=0; i<4; i++)
21476 {
21477
1/2
✓ Branch 0 taken 5104116 times.
✗ Branch 1 not taken.
5104116 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21478 {
21479 if(types[i] == cSAVE || types[i] == cSAVE2)
21480 {
21481 types[i] = cNONE;
21482 setsave = false;
21483 break;
21484 }
21485 }
21486
2/2
✓ Branch 0 taken 5102830 times.
✓ Branch 1 taken 1286 times.
5104116 if(types[i]==cSAVE) setsave=true;
21487
21488
1/2
✓ Branch 0 taken 5104116 times.
✗ Branch 1 not taken.
5104116 if(types[i]==cSAVE2) setsave=true;
21489 5104116 }
21490
21491
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 1275598 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
1276029 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21492 {
21493 229 last_savepoint_id = cids[0];
21494 229 type = types[0];
21495 229 }
21496 //
21497 // Now, let's check for Drowning combos...
21498 //
21499
3/4
✓ Branch 0 taken 656331 times.
✓ Branch 1 taken 619698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 656331 times.
1276029 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
21500 {
21501 619698 y1 = ty+9;
21502 619698 y2 = ty+15;
21503
2/2
✓ Branch 0 taken 218489 times.
✓ Branch 1 taken 401209 times.
619698 if (get_bit(quest_rules, qr_SMARTER_WATER))
21504 {
21505
4/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 216601 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1598 times.
220090 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
21506
2/2
✓ Branch 0 taken 1724 times.
✓ Branch 1 taken 164 times.
1888 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
21507
2/2
✓ Branch 0 taken 1601 times.
✓ Branch 1 taken 123 times.
1724 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
21508 1601 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
21509 218489 }
21510 else
21511 {
21512 401209 types[0] = COMBOTYPE(x1,y1);
21513
21514
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 389911 times.
401209 if(MAPFFCOMBO(x1,y1))
21515 11298 types[0] = FFCOMBOTYPE(x1,y1);
21516
21517 401209 types[1] = COMBOTYPE(x1,y2);
21518
21519
2/2
✓ Branch 0 taken 10865 times.
✓ Branch 1 taken 390344 times.
401209 if(MAPFFCOMBO(x1,y2))
21520 10865 types[1] = FFCOMBOTYPE(x1,y2);
21521
21522 401209 types[2] = COMBOTYPE(x2,y1);
21523
21524
2/2
✓ Branch 0 taken 12012 times.
✓ Branch 1 taken 389197 times.
401209 if(MAPFFCOMBO(x2,y1))
21525 12012 types[2] = FFCOMBOTYPE(x2,y1);
21526
21527 401209 types[3] = COMBOTYPE(x2,y2);
21528
21529
2/2
✓ Branch 0 taken 11355 times.
✓ Branch 1 taken 389854 times.
401209 if(MAPFFCOMBO(x2,y2))
21530 11355 types[3] = FFCOMBOTYPE(x2,y2);
21531
21532 401209 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
21533
2/2
✓ Branch 0 taken 11559 times.
✓ Branch 1 taken 389650 times.
401209 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
21534 11559 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
21535
21536
5/6
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 399317 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1852 times.
✗ Branch 5 not taken.
403061 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
21537
3/4
✓ Branch 0 taken 1852 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 1852 times.
✗ Branch 3 not taken.
1888 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
21538 1852 water = typec;
21539 }
21540 619698 }
21541
21542
21543 // Pits have a bigger 'hitbox' than stairs...
21544 1276029 x1 = tx+7;
21545 1276029 x2 = tx+8;
21546 1276029 y1 = ty+7+(bigHitbox?0:4);
21547 1276029 y2 = ty+8+(bigHitbox?0:4);
21548
21549 1276029 types[0] = COMBOTYPE(x1,y1);
21550 1276029 cids[0] = MAPCOMBO(x1,y1);
21551
21552
2/2
✓ Branch 0 taken 1259849 times.
✓ Branch 1 taken 16180 times.
1276029 if(MAPFFCOMBO(x1,y1))
21553 {
21554 16180 types[0] = FFCOMBOTYPE(x1,y1);
21555 16180 cids[0] = MAPFFCOMBO(x1,y1);
21556 16180 }
21557
21558 1276029 types[1] = COMBOTYPE(x1,y2);
21559 1276029 cids[1] = MAPCOMBO(x1,y2);
21560
21561
2/2
✓ Branch 0 taken 1259922 times.
✓ Branch 1 taken 16107 times.
1276029 if(MAPFFCOMBO(x1,y2))
21562 {
21563 16107 types[1] = FFCOMBOTYPE(x1,y2);
21564 16107 cids[1] = MAPFFCOMBO(x1,y2);
21565 16107 }
21566 1276029 types[2] = COMBOTYPE(x2,y1);
21567 1276029 cids[2] = MAPCOMBO(x2,y1);
21568
21569
2/2
✓ Branch 0 taken 1260198 times.
✓ Branch 1 taken 15831 times.
1276029 if(MAPFFCOMBO(x2,y1))
21570 {
21571 15831 types[2] = FFCOMBOTYPE(x2,y1);
21572 15831 cids[2] = MAPFFCOMBO(x2,y1);
21573 15831 }
21574
21575 1276029 types[3] = COMBOTYPE(x2,y2);
21576 1276029 cids[3] = MAPCOMBO(x2,y2);
21577
21578
2/2
✓ Branch 0 taken 1260266 times.
✓ Branch 1 taken 15763 times.
1276029 if(MAPFFCOMBO(x2,y2))
21579 {
21580 15763 types[3] = FFCOMBOTYPE(x2,y2);
21581 15763 cids[3] = MAPFFCOMBO(x2,y2);
21582 15763 }
21583
21584
2/2
✓ Branch 0 taken 5104116 times.
✓ Branch 1 taken 1276029 times.
6380145 for(int32_t i=0; i<4; i++)
21585 {
21586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5104116 times.
5104116 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21587 {
21588 types[i] = cNONE;
21589 continue;
21590 }
21591
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 5103990 times.
5104116 if(types[i]==cPIT)
21592 {
21593 126 index=0;
21594 126 warpsfx2 = combobuf[cids[i]].attribytes[0];
21595 126 }
21596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103990 times.
5103990 else if(types[i]==cPITB)
21597 {
21598 types[i]=cPIT;
21599 index=1;
21600 warpsfx2 = combobuf[cids[i]].attribytes[0];
21601 }
21602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5103990 times.
5103990 else if(types[i]==cPITC)
21603 {
21604 types[i]=cPIT;
21605 index=2;
21606 warpsfx2 = combobuf[cids[i]].attribytes[0];
21607 }
21608
1/2
✓ Branch 0 taken 5103990 times.
✗ Branch 1 not taken.
5103990 else if(types[i]==cPITD)
21609 {
21610 types[i]=cPIT;
21611 index=3;
21612 warpsfx2 = combobuf[cids[i]].attribytes[0];
21613 }
21614 5104116 }
21615
21616
6/8
✓ Branch 0 taken 1275998 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 1275998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1275997 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1275997 times.
1276029 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
21617
3/8
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
64 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21618 32 type=cPIT;
21619
21620 //
21621 // Time to act on our results for type, flag, flag2 and flag3...
21622 //
21623
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 1275800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
1276029 if(type==cSAVE&&currscr<128)
21624 229 *ls=1;
21625
21626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1276029 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1276029 if(type==cSAVE2&&currscr<128)
21627 *ls=2;
21628
21629
7/8
✓ Branch 0 taken 1270229 times.
✓ Branch 1 taken 5800 times.
✓ Branch 2 taken 1263101 times.
✓ Branch 3 taken 7128 times.
✓ Branch 4 taken 1262571 times.
✓ Branch 5 taken 530 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1262571 times.
1276029 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
21630 {
21631 13458 fairycircle(REFILL_LIFE);
21632
21633
2/2
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 1907 times.
13458 if(fairyclk!=0) return;
21634 1907 }
21635
21636
4/8
✓ Branch 0 taken 1264478 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1264478 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1264478 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1264478 times.
1264478 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
21637 {
21638 fairycircle(REFILL_MAGIC);
21639
21640 if(fairyclk!=0) return;
21641 }
21642
21643
4/8
✓ Branch 0 taken 1264478 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1264478 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1264478 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1264478 times.
1264478 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
21644 {
21645 fairycircle(REFILL_ALL);
21646
21647 if(fairyclk!=0) return;
21648 }
21649
21650 // Just in case Hero was moved off of the fairy flag
21651
1/2
✓ Branch 0 taken 1264478 times.
✗ Branch 1 not taken.
1264478 if(refilling==REFILL_FAIRYDONE)
21652 {
21653 fairycircle(REFILL_NONE);
21654
21655 if(fairyclk!=0) return;
21656 }
21657
21658
5/8
✓ Branch 0 taken 1264474 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1264474 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1264474 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1264474 times.
1264478 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
21659 {
21660 4 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
21661 4 win_game();
21662 4 return;
21663 }
21664
21665
4/4
✓ Branch 0 taken 1261274 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 1261274 times.
✓ Branch 3 taken 3200 times.
1264474 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
21666 3200 return;
21667
21668
3/4
✓ Branch 0 taken 1261274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1261273 times.
1261274 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
21669 {
21670
21671
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
21672 {
21673 1 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
21674 1 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
21675 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
21676
21677
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(type==cTRIGFLAG && canPermSecret())
21678 {
21679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
21680
21681 1 hidden_entrance(0,true,false);
21682 1 }
21683 else
21684 {
21685 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21686 hidden_entrance(0,true,only16_31);
21687 }
21688 1 }
21689 1 }
21690
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1260931 times.
1261273 else if(!didstrig)
21691 {
21692 1260931 stepsecret = -1;
21693 1260931 }
21694
21695 //Better? Dock collision
21696
21697 // Drown if:
21698 // * Water (obviously walkable),
21699 // * Quest Rule allows it,
21700 // * Not on stepladder,
21701 // * Not jumping,
21702 // * Not hovering,
21703 // * Not rafting,
21704 // * Not swallowed,
21705 // * Not a dried lake.
21706
21707 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
21708
21709
13/22
✓ Branch 0 taken 3394 times.
✓ Branch 1 taken 1257880 times.
✓ Branch 2 taken 3394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3394 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3394 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3394 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 3387 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3011 times.
✓ Branch 15 taken 376 times.
✓ Branch 16 taken 3011 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3011 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1261274 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
21710 {
21711
4/8
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3011 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
21712 {
21713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!(ladderx+laddery)) drownCombo = water;
21714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (combobuf[water].usrflags&cflag1) Drown(1);
21715 11 else Drown();
21716
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 if(byte drown_sfx = combobuf[water].attribytes[4])
21717 8 sfx(drown_sfx, pan(int32_t(x)));
21718 11 }
21719
2/2
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 109 times.
3000 else if (!isSwimming())
21720 {
21721 109 SetSwim();
21722
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if (!IsSideSwim()) attackclk = charging = spins = 0;
21723 109 landswim=0;
21724 109 return;
21725 }
21726 2902 }
21727
21728
21729
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 1261002 times.
1261165 if(type==cSTEP)
21730 {
21731 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
21732
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 66 times.
163 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
21733 {
21734 66 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
21735
21736 if
21737 (
21738
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
21739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
21740 && /*HEAVY*/
21741
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21742 )
21743
21744 {
21745 62 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
21746 62 tmpscr->data[stepnext]++;
21747
21748 62 }
21749
21750 if
21751 (
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
21753 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21754 && /*HEAVY*/
21755 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21756 )
21757 {
21758 int32_t stepc = tmpscr->data[stepnext];
21759 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21760 for(int32_t k=0; k<176; k++)
21761 {
21762 if(tmpscr->data[k]==stepc)
21763 {
21764 tmpscr->data[k]++;
21765 }
21766 }
21767 }
21768
21769 if
21770 (
21771
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 63 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
21772
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21773 && /*HEAVY*/
21774
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21775 )
21776 {
21777 3 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21778
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 for(int32_t k=0; k<176; k++)
21779 {
21780 if(
21781
3/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 507 times.
1050 (combobuf[tmpscr->data[k]].type==cSTEP)||
21782
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
21783
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 6 times.
528 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
21784 522 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
21785 )
21786 {
21787 21 tmpscr->data[k]++;
21788 21 }
21789 528 }
21790 3 }
21791 66 }
21792 163 }
21793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1261002 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1261002 else if(type==cSTEPSFX && action == walking)
21794 {
21795 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
21796 }
21797 1261002 else stepnext = -1;
21798
21799 1261165 detail_int[0]=tx;
21800 1261165 detail_int[1]=ty;
21801
21802
21803
6/8
✓ Branch 0 taken 1261023 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 169 times.
✓ Branch 3 taken 1260996 times.
✓ Branch 4 taken 1260409 times.
✓ Branch 5 taken 587 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1261165 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
21804
5/6
✓ Branch 0 taken 1260377 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 1260372 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 1260372 times.
✗ Branch 5 not taken.
1260409 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
21805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1260372 times.
1260372 !(type==cDIVEWARP && isDiving()))
21806 1260372 {
21807 RaftingStuff:
21808
2/2
✓ Branch 0 taken 1259813 times.
✓ Branch 1 taken 559 times.
1260372 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
21809 {
21810 559 bool doraft = true;
21811
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
21812 {
21813
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21814 {
21815 3 doraft = false;
21816 3 }
21817 3 }
21818 //if (mfRAFT)
21819 int32_t rafttypes[2];
21820 559 int32_t raftx1 = tx+6;
21821 559 int32_t raftx2 = tx+9;
21822 559 int32_t rafty = ty+11;
21823 int32_t raftflags[3];
21824 559 rafttypes[0]=rafttypes[1]=-1;
21825 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
21826 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
21827 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
21828
21829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21830 559 raftflags[0] = rafttypes[0];
21831
21832
21833 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
21834 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
21835
21836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21837 559 raftflags[1] = rafttypes[0];
21838
21839 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
21840 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
21841
21842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21843 559 raftflags[2] = rafttypes[0];
21844
21845
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
21846 {
21847
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
21848 {
21849 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
21850 {
21851 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
21852 {
21853 reset_swordcharge();
21854 action=rafting; FFCore.setHeroAction(rafting);
21855 raftclk=0;
21856 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21857 else sfx(tmpscr->secretsfx);
21858 }
21859 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21860 {
21861 for (int32_t i = 0; i < 4; ++i)
21862 {
21863 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
21864 {
21865 reset_swordcharge();
21866 action=rafting; FFCore.setHeroAction(rafting);
21867 raftclk=0;
21868 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21869 else sfx(tmpscr->secretsfx);
21870 dir = i;
21871 break;
21872 }
21873 }
21874 }
21875 }
21876 }
21877 1677 }
21878 559 }
21879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1260372 times.
1260372 if (RaftPass) return;
21880
3/3
✓ Branch 0 taken 2714 times.
✓ Branch 1 taken 1257255 times.
✓ Branch 2 taken 403 times.
1260372 switch(flag)
21881 {
21882 case mfDIVE_ITEM:
21883
6/8
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 396 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
403 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21884 {
21885 8 additem(x, y, tmpscr->catchall,
21886 4 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21887 4 sfx(tmpscr->secretsfx);
21888 4 }
21889
21890 403 return;
21891
21892 case mfRAFT:
21893 case mfRAFT_BRANCH:
21894
21895 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2714 times.
2714 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21897 {
21898 2714 bool doraft = true;
21899
5/6
✓ Branch 0 taken 2714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 2220 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 428 times.
2714 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21900 {
21901
4/6
✓ Branch 0 taken 428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 411 times.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
428 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21902 {
21903 doraft = false;
21904 }
21905 428 }
21906
12/16
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 359 times.
✓ Branch 3 taken 2153 times.
✓ Branch 4 taken 359 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 357 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 357 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 357 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 357 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 185 times.
✓ Branch 15 taken 172 times.
2714 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21907 {
21908
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
172 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
21909 {
21910 132 reset_swordcharge();
21911 132 action=rafting; FFCore.setHeroAction(rafting);
21912 132 raftclk=0;
21913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21914 132 else sfx(tmpscr->secretsfx);
21915 132 }
21916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21917 {
21918 for (int32_t i = 0; i < 4; ++i)
21919 {
21920 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21921 {
21922 reset_swordcharge();
21923 action=rafting; FFCore.setHeroAction(rafting);
21924 raftclk=0;
21925 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21926 else sfx(tmpscr->secretsfx);
21927 dir = i;
21928 break;
21929 }
21930 }
21931 }
21932 172 }
21933 2714 }
21934
21935 2714 return;
21936
21937 default:
21938 1257255 break;
21939 //return;
21940 }
21941
21942
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1257255 times.
✗ Branch 2 not taken.
1257255 switch(flag2)
21943 {
21944 case mfDIVE_ITEM:
21945 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21946 {
21947 additem(x, y, tmpscr->catchall,
21948 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21949 sfx(tmpscr->secretsfx);
21950 }
21951
21952 return;
21953
21954 case mfRAFT:
21955 case mfRAFT_BRANCH:
21956
21957 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21958 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21959 {
21960 bool doraft = true;
21961 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21962 {
21963 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21964 {
21965 doraft = false;
21966 }
21967 }
21968 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21969 {
21970 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
21971 {
21972 reset_swordcharge();
21973 action=rafting; FFCore.setHeroAction(rafting);
21974 raftclk=0;
21975 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21976 else sfx(tmpscr->secretsfx);
21977 }
21978 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21979 {
21980 for (int32_t i = 0; i < 4; ++i)
21981 {
21982 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21983 {
21984 reset_swordcharge();
21985 action=rafting; FFCore.setHeroAction(rafting);
21986 raftclk=0;
21987 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21988 else sfx(tmpscr->secretsfx);
21989 dir = i;
21990 break;
21991 }
21992 }
21993 }
21994 }
21995 }
21996
21997 return;
21998
21999 default:
22000 1257255 break;
22001 //return;
22002 }
22003
22004
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1257255 times.
✗ Branch 2 not taken.
1257255 switch(flag3)
22005 {
22006 case mfDIVE_ITEM:
22007 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
22008 {
22009 additem(x, y, tmpscr->catchall,
22010 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22011 sfx(tmpscr->secretsfx);
22012 }
22013
22014 return;
22015
22016 case mfRAFT:
22017 case mfRAFT_BRANCH:
22018
22019 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22020 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22021 {
22022 bool doraft = true;
22023 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22024 {
22025 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22026 {
22027 doraft = false;
22028 }
22029 }
22030 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22031 {
22032 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22033 {
22034 reset_swordcharge();
22035 action=rafting; FFCore.setHeroAction(rafting);
22036 raftclk=0;
22037 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22038 else sfx(tmpscr->secretsfx);
22039 }
22040 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22041 {
22042 for (int32_t i = 0; i < 4; ++i)
22043 {
22044 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22045 {
22046 reset_swordcharge();
22047 action=rafting; FFCore.setHeroAction(rafting);
22048 raftclk=0;
22049 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22050 else sfx(tmpscr->secretsfx);
22051 dir = i;
22052 break;
22053 }
22054 }
22055 }
22056 }
22057 }
22058
22059 return;
22060
22061 default:
22062 1257255 return;
22063 }
22064 }
22065
22066
22067 793 int32_t t=(currscr<128)?0:1;
22068
22069
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 793 times.
✗ Branch 3 not taken.
793 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
22070
22071 //don't do this for canceled warps -DD
22072 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
22073 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
22074 {
22075 draw_screen(tmpscr);
22076 advanceframe(true);
22077 }*/
22078
22079 793 bool skippedaframe=false;
22080
22081
6/6
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 624 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 37 times.
793 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
22082 {
22083 // Stop music only if:
22084 // * entering a Guy Cave
22085 // * warping to a DMap whose music is different.
22086
22087 756 int32_t tdm = tmpscr[t].tilewarpdmap[index];
22088
22089
2/2
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 193 times.
756 if(tmpscr[t].tilewarptype[index]<=wtPASS)
22090 {
22091
3/4
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 267 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 296 times.
563 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
22092 296 music_stop();
22093 563 }
22094 else
22095 {
22096
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 183 times.
193 if(zcmusic!=NULL)
22097 {
22098
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
22099
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
22100 10 music_stop();
22101 10 }
22102
3/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 178 times.
183 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
22103 178 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
22104 178 music_stop();
22105 }
22106
22107 756 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
22108
5/6
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 267 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
756 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
22109 489 ? false : COOLSCROLL);
22110
22111 756 FFCore.warpScriptCheck();
22112 756 draw_screen(tmpscr);
22113 756 advanceframe(true);
22114
22115 756 skippedaframe=true;
22116
22117
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 729 times.
756 if(type==cCAVE2) walkup2(opening);
22118
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 142 times.
729 else if(type==cCAVE) walkdown(opening);
22119 756 }
22120
22121
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 32 times.
793 if(type==cPIT)
22122 {
22123 32 didpit=true;
22124 32 pitx=x;
22125 32 pity=y;
22126 32 warp_sound = warpsfx2;
22127 32 }
22128
22129
5/6
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 386 times.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
848 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
22130
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
441 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
22131 {
22132
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!skippedaframe)
22133 {
22134 FFCore.warpScriptCheck();
22135 draw_screen(tmpscr);
22136 advanceframe(true);
22137 }
22138
22139 // "take any road you want"
22140
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
22141 55 int32_t code = WARPCODE(currdmap,homescr,dw);
22142
22143
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(code>-1)
22144 {
22145 55 bool changedlevel = false;
22146 55 bool changeddmap = false;
22147
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 if(currdmap != code>>8)
22148 {
22149 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22150 15 changeddmap = true;
22151 15 }
22152
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(dlevel != DMaps[code>>8].level)
22153 {
22154 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22155 changedlevel = true;
22156 }
22157 55 currdmap = code>>8;
22158 55 dlevel = DMaps[currdmap].level;
22159
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 if(changeddmap)
22160 {
22161 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22162 15 }
22163
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(changedlevel)
22164 {
22165 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22166 }
22167
22168 55 currmap = DMaps[currdmap].map;
22169 55 homescr = (code&0xFF) + DMaps[currdmap].xoff;
22170 55 init_dmap();
22171
22172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(canPermSecret())
22173 55 setmapflag(mSECRET);
22174 55 }
22175
22176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(specialcave==STAIRCAVE) exitcave();
22177
22178 55 return;
22179 }
22180
22181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 738 times.
738 if(type==cRESET)
22182 {
22183 if(!skippedaframe)
22184 {
22185 FFCore.warpScriptCheck();
22186 draw_screen(tmpscr);
22187 advanceframe(true);
22188 }
22189
22190 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
22191
22192 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
22193
22194 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
22195
22196 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
22197
22198 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
22199
22200 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
22201
22202 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
22203
22204 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
22205
22206 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
22207
22208 if(isdungeon())
22209 {
22210 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
22211
22212 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
22213
22214 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
22215
22216 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
22217 }
22218
22219 didpit=true;
22220 pitx=x;
22221 pity=y;
22222 sdir=dir;
22223 dowarp(4,0, warpsfx2);
22224 }
22225 else
22226 {
22227
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
738 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
22228 {
22229 37 FFCore.warpScriptCheck();
22230 37 draw_screen(tmpscr);
22231 37 advanceframe(true);
22232 37 }
22233
22234 738 sdir = dir;
22235 738 dowarp(0,index, warpsfx2);
22236 }
22237 3624243 }
22238
22239 21 int32_t selectWlevel(int32_t d)
22240 {
22241
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(TriforceCount()==0)
22242 return 0;
22243
22244 21 word l = game->get_wlevel();
22245
22246 21 do
22247 {
22248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
22249 break;
22250
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 18 times.
50 else if(d<0)
22251
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 3 times.
18 l = (l==0) ? 7 : l-1;
22252 else
22253
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28 times.
32 l = (l==7) ? 0 : l+1;
22254
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 21 times.
50 }
22255 50 while(!(game->lvlitems[l+1] & liTRIFORCE));
22256
22257 21 game->set_wlevel(l);
22258 21 return l;
22259 21 }
22260
22261 // Would someone tell the Dodongos to shut their yaps?!
22262 6013 void kill_enemy_sfx()
22263 {
22264
2/2
✓ Branch 0 taken 6013 times.
✓ Branch 1 taken 11451 times.
17464 for(int32_t i=0; i<guys.Count(); i++)
22265 {
22266
2/2
✓ Branch 0 taken 7353 times.
✓ Branch 1 taken 4098 times.
11451 if(((enemy*)guys.spr(i))->bgsfx)
22267 4098 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
22268 11451 }
22269
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5993 times.
6013 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
22270
2/2
✓ Branch 0 taken 6008 times.
✓ Branch 1 taken 5 times.
6013 if(tmpscr->room==rGANON)
22271 5 stop_sfx(WAV_ROAR);
22272 6013 }
22273
22274 675 bool HeroClass::HasHeavyBoots()
22275 {
22276
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 172800 times.
173475 for ( int32_t q = 0; q < MAXITEMS; ++q )
22277 {
22278
5/6
✓ Branch 0 taken 1999 times.
✓ Branch 1 taken 170801 times.
✓ Branch 2 taken 649 times.
✓ Branch 3 taken 1350 times.
✓ Branch 4 taken 649 times.
✗ Branch 5 not taken.
172800 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
22279 172800 }
22280 675 return false;
22281 675 }
22282
22283 const char *roomtype_string[rMAX] =
22284 {
22285 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
22286 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
22287 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
22288 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
22289 };
22290
22291 1100 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
22292 {
22293 1100 byte reposition_sword_postwarp = 0;
22294
1/2
✓ Branch 0 taken 1100 times.
✗ Branch 1 not taken.
1100 if(index<0)
22295 {
22296 return false;
22297 }
22298 1100 is_warping = true;
22299
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 1100 times.
1263 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
22300 {
22301 163 weapon *swd=NULL;
22302 163 swd = (weapon*)Lwpns.spr(q);
22303
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 8 times.
163 if(swd->id == (attack==wSword ? wSword : wWand))
22304 {
22305 8 Lwpns.del(q);
22306 8 }
22307 163 }
22308
22309 1100 attackclk = charging = spins = tapping = 0;
22310 1100 attack = none;
22311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1100 times.
1100 if ( warp_sound > 0 ) warpsfx = warp_sound;
22312 1100 warp_sound = 0;
22313 1100 word wdmap=0;
22314 1100 byte wscr=0,wtype=0,t=0;
22315 1100 bool overlay=false;
22316 1100 t=(currscr<128)?0:1;
22317 1100 int32_t wrindex = 0;
22318 1100 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
22319
22320 // Drawing commands probably shouldn't carry over...
22321
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1094 times.
1100 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
22322 1094 script_drawing_commands.Clear();
22323
22324
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 741 times.
✓ Branch 2 taken 333 times.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1100 switch(type)
22325 {
22326 case 0: // tile warp
22327 741 wtype = tmpscr[t].tilewarptype[index];
22328 741 wdmap = tmpscr[t].tilewarpdmap[index];
22329 741 wscr = tmpscr[t].tilewarpscr[index];
22330 741 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
22331 741 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
22332 741 break;
22333
22334 case 1: // side warp
22335 333 wtype = tmpscr[t].sidewarptype[index];
22336 333 wdmap = tmpscr[t].sidewarpdmap[index];
22337 333 wscr = tmpscr[t].sidewarpscr[index];
22338 333 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
22339 333 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
22340 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
22341 //there is no doscript for screen scripts. They run like ffcs.
22342
22343 333 break;
22344
22345 case 2: // whistle warp
22346 {
22347 20 wtype = wtWHISTLE;
22348
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
22349 20 int32_t level=0;
22350
22351
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(blowcnt==0)
22352 level = selectWlevel(0);
22353 else
22354 {
22355
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 for(int32_t i=0; i<abs(blowcnt); i++)
22356 21 level = selectWlevel(blowcnt);
22357 }
22358
22359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
22360 {
22361 level %= QMisc.warp[wind].size;
22362 game->set_wlevel(level);
22363 }
22364
22365 20 wdmap = QMisc.warp[wind].dmap[level];
22366 20 wscr = QMisc.warp[wind].scr[level];
22367 }
22368 20 break;
22369
22370 case 3:
22371 wtype = wtIWARP;
22372 wdmap = cheat_goto_dmap;
22373 wscr = cheat_goto_screen;
22374 break;
22375
22376 case 4:
22377 wtype = wtIWARP;
22378 wdmap = currdmap;
22379 wscr = homescr-DMaps[currdmap].xoff;
22380 break;
22381 }
22382
22383 1100 bool intradmap = (wdmap == currdmap);
22384 1100 int32_t olddmap = currdmap;
22385 1100 rehydratelake(type!=wtSCROLL);
22386
22387
7/8
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 338 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 188 times.
✓ Branch 5 taken 124 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 37 times.
1100 switch(wtype)
22388 {
22389 case wtCAVE:
22390 {
22391 // cave/item room
22392 338 ALLOFF();
22393 338 homescr=currscr;
22394 338 currscr=0x80;
22395
22396
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 97 times.
338 if(DMaps[currdmap].flags&dmfCAVES) // cave
22397 {
22398 241 music_stop();
22399 241 kill_sfx();
22400
22401
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 181 times.
241 if(tmpscr->room==rWARP)
22402 {
22403 60 currscr=0x81;
22404 60 specialcave = STAIRCAVE;
22405 60 }
22406 181 else specialcave = GUYCAVE;
22407
22408 //lighting(2,dir);
22409 241 lighting(false, true);
22410 241 loadlvlpal(10);
22411
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 38 times.
444 bool b2 = COOLSCROLL&&
22412
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
203 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
22413
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
22414
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
22415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
22416 241 blackscr(30,b2?false:true);
22417 241 loadscr(0,wdmap,currscr,up,false);
22418 241 loadscr(1,wdmap,homescr,up,false);
22419 //preloaded freeform combos
22420 241 ffscript_engine(true);
22421 241 putscr(scrollbuf,0,0,tmpscr);
22422 241 putscrdoors(scrollbuf,0,0,tmpscr);
22423 241 dir=up;
22424 241 x=112;
22425 241 y=160;
22426
1/2
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
241 if(didpit)
22427 {
22428 didpit=false;
22429 x=pitx;
22430 y=pity;
22431 }
22432
22433 241 reset_hookshot();
22434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241 times.
241 if(reposition_sword_postwarp)
22435 {
22436 weapon *swd=NULL;
22437 for(int32_t i=0; i<Lwpns.Count(); i++)
22438 {
22439 swd = (weapon*)Lwpns.spr(i);
22440
22441 if(swd->id == (attack==wSword ? wSword : wWand))
22442 {
22443 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22444 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22445 positionSword(swd,item_id);
22446 break;
22447 }
22448 }
22449 }
22450 241 stepforward(diagonalMovement?5:6, false);
22451 241 }
22452 else // item room
22453 {
22454 97 specialcave = ITEMCELLAR;
22455 97 map_bkgsfx(false);
22456 97 kill_enemy_sfx();
22457 97 draw_screen(tmpscr,false);
22458
22459 //unless the room is already dark, fade to black
22460
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 96 times.
97 if(!darkroom)
22461 {
22462 96 darkroom = true;
22463 96 fade(DMaps[currdmap].color,true,false);
22464 96 }
22465
22466 97 blackscr(30,true);
22467 97 loadscr(0,wdmap,currscr,down,false);
22468 97 loadscr(1,wdmap,homescr,-1,false);
22469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if ( dontdraw < 2 ) { dontdraw=1; }
22470 97 draw_screen(tmpscr);
22471 97 fade(11,true,true);
22472 97 darkroom = false;
22473 97 dir=down;
22474 97 x=48;
22475 97 y=0;
22476
22477 // is this didpit check necessary?
22478
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(didpit)
22479 {
22480 didpit=false;
22481 x=pitx;
22482 y=pity;
22483 }
22484
22485 97 reset_hookshot();
22486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(reposition_sword_postwarp)
22487 {
22488 weapon *swd=NULL;
22489 for(int32_t i=0; i<Lwpns.Count(); i++)
22490 {
22491 swd = (weapon*)Lwpns.spr(i);
22492
22493 if(swd->id == (attack==wSword ? wSword : wWand))
22494 {
22495 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22496 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22497 positionSword(swd,item_id);
22498 break;
22499 }
22500 }
22501 }
22502 97 lighting(false, true);
22503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if ( dontdraw < 2 ) { dontdraw=0; }
22504 97 stepforward(diagonalMovement?16:18, false);
22505 }
22506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
22507 338 break;
22508 }
22509
22510 case wtPASS: // passageway
22511 {
22512 170 map_bkgsfx(false);
22513 170 kill_enemy_sfx();
22514 170 ALLOFF();
22515 //play sound
22516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22517 170 homescr=currscr;
22518 170 currscr=0x81;
22519 170 specialcave = PASSAGEWAY;
22520 170 byte warpscr2 = wscr + DMaps[wdmap].xoff;
22521 170 draw_screen(tmpscr,false);
22522
22523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
22524 {
22525
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 162 times.
170 if(!darkroom)
22526 162 fade(DMaps[currdmap].color,true,false);
22527
22528 170 darkroom=true;
22529 170 }
22530 170 blackscr(30,true);
22531 170 loadscr(0,wdmap,currscr,down,false);
22532 170 loadscr(1,wdmap,homescr,-1,false);
22533 //preloaded freeform combos
22534 170 ffscript_engine(true);
22535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if ( dontdraw < 2 ) { dontdraw=1; }
22536 170 draw_screen(tmpscr);
22537 170 lighting(false, true);
22538 170 dir=down;
22539 170 x=48;
22540
22541
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 85 times.
170 if((homescr&15) > (warpscr2&15))
22542 {
22543 85 x=192;
22544 85 }
22545
22546
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 1 times.
170 if((homescr&15) == (warpscr2&15))
22547 {
22548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if((currscr>>4) > (warpscr2>>4))
22549 {
22550 1 x=192;
22551 1 }
22552 1 }
22553
22554 // is this didpit check necessary?
22555
1/2
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
170 if(didpit)
22556 {
22557 didpit=false;
22558 x=pitx;
22559 y=pity;
22560 }
22561
22562 170 y=0;
22563 170 set_respawn_point();
22564 170 trySideviewLadder();
22565 170 reset_hookshot();
22566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if(reposition_sword_postwarp)
22567 {
22568 weapon *swd=NULL;
22569 for(int32_t i=0; i<Lwpns.Count(); i++)
22570 {
22571 swd = (weapon*)Lwpns.spr(i);
22572
22573 if(swd->id == (attack==wSword ? wSword : wWand))
22574 {
22575 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22576 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22577 positionSword(swd,item_id);
22578 break;
22579 }
22580 }
22581 }
22582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if ( dontdraw < 2 ) { dontdraw=0; }
22583 170 stepforward(diagonalMovement?16:18, false);
22584 170 newscr_clk=frame;
22585 170 activated_timed_warp=false;
22586 170 stepoutindex=index;
22587 170 stepoutscr = warpscr2;
22588 170 stepoutdmap = wdmap;
22589 170 stepoutwr=wrindex;
22590 }
22591 170 break;
22592
22593 case wtEXIT: // entrance/exit
22594 {
22595 188 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
22596 188 ALLOFF();
22597 188 music_stop();
22598 188 kill_sfx();
22599 188 blackscr(30,false);
22600 188 bool changedlevel = false;
22601 188 bool changeddmap = false;
22602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
188 if(currdmap != wdmap)
22603 {
22604 188 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22605 188 changeddmap = true;
22606 188 }
22607
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 187 times.
188 if(dlevel != DMaps[wdmap].level)
22608 {
22609 187 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22610 187 changedlevel = true;
22611 187 }
22612 188 dlevel = DMaps[wdmap].level;
22613 188 currdmap = wdmap;
22614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
188 if(changeddmap)
22615 {
22616 188 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22617 188 }
22618
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 187 times.
188 if(changedlevel)
22619 {
22620 187 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22621 187 }
22622
22623 188 currmap=DMaps[currdmap].map;
22624 188 init_dmap();
22625 188 update_subscreens(wdmap);
22626 188 loadfullpal();
22627 188 ringcolor(false);
22628 188 loadlvlpal(DMaps[currdmap].color);
22629 //lastentrance_dmap = currdmap;
22630 188 homescr = currscr = wscr + DMaps[currdmap].xoff;
22631 188 loadscr(0,currdmap,currscr,-1,overlay);
22632
22633
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
188 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
22634 {
22635
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules,qr_FADE))
22636 {
22637 interpolatedfade();
22638 }
22639 else
22640 {
22641 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
22642 }
22643
22644 3 darkroom=naturaldark=true;
22645 3 }
22646 else
22647 {
22648 185 darkroom=naturaldark=false;
22649 }
22650
22651 int32_t wrx,wry;
22652
22653
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 174 times.
188 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22654 {
22655 14 wrx=tmpscr->warpreturnx[0];
22656 14 wry=tmpscr->warpreturny[0];
22657 14 }
22658 else
22659 {
22660 174 wrx=tmpscr->warparrivalx;
22661 174 wry=tmpscr->warparrivaly;
22662 }
22663
22664
6/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 162 times.
188 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22665 {
22666
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 58 times.
162 if(dlevel)
22667 {
22668 104 lastentrance = currscr;
22669 104 }
22670 else
22671 {
22672 58 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22673 }
22674
22675 162 lastentrance_dmap = wdmap;
22676 162 }
22677
22678
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 84 times.
188 if(dlevel)
22679 {
22680
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22681 {
22682 7 x=tmpscr->warpreturnx[wrindex];
22683 7 y=tmpscr->warpreturny[wrindex];
22684 7 }
22685 else
22686 {
22687 97 x=tmpscr->warparrivalx;
22688 97 y=tmpscr->warparrivaly;
22689 }
22690 104 }
22691 else
22692 {
22693 84 x=tmpscr->warpreturnx[wrindex];
22694 84 y=tmpscr->warpreturny[wrindex];
22695 }
22696
22697
1/2
✓ Branch 0 taken 188 times.
✗ Branch 1 not taken.
188 if(didpit)
22698 {
22699 didpit=false;
22700 x=pitx;
22701 y=pity;
22702 }
22703
22704 188 dir=down;
22705
22706
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 176 times.
188 if(x==0) dir=right;
22707
22708
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 180 times.
188 if(x==240) dir=left;
22709
22710
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 182 times.
188 if(y==0) dir=down;
22711
22712
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 110 times.
188 if(y==160) dir=up;
22713
22714
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 84 times.
188 if(dlevel)
22715 {
22716 // reset enemy kill counts
22717
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 104 times.
13416 for(int32_t i=0; i<128; i++)
22718 {
22719 13312 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
22720 13312 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
22721 13312 }
22722 104 }
22723
22724 188 markBmap(dir^1);
22725 //preloaded freeform combos
22726 188 ffscript_engine(true);
22727
22728 188 reset_hookshot();
22729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
188 if(reposition_sword_postwarp)
22730 {
22731 weapon *swd=NULL;
22732 for(int32_t i=0; i<Lwpns.Count(); i++)
22733 {
22734 swd = (weapon*)Lwpns.spr(i);
22735
22736 if(swd->id == (attack==wSword ? wSword : wWand))
22737 {
22738 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22739 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22740 positionSword(swd,item_id);
22741 break;
22742 }
22743 }
22744 }
22745
22746
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 91 times.
188 if(isdungeon())
22747 {
22748 97 openscreen();
22749
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
97 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
22750 97 stepforward(diagonalMovement?11:12, false);
22751 else
22752 // Didn't walk as far pre-1.93, and some quests depend on that
22753 stepforward(8, false);
22754 97 }
22755 else
22756 {
22757
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 68 times.
91 if(!COOLSCROLL)
22758 23 openscreen();
22759
22760 91 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
22761 91 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22762 91 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
22763
22764
5/10
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
91 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
22765 {
22766 53 reset_pal_cycling();
22767 53 putscr(scrollbuf,0,0,tmpscr);
22768 53 putscrdoors(scrollbuf,0,0,tmpscr);
22769 53 walkup(COOLSCROLL);
22770 53 }
22771
5/10
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 35 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
38 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
22772 {
22773 3 reset_pal_cycling();
22774 3 putscr(scrollbuf,0,0,tmpscr);
22775 3 putscrdoors(scrollbuf,0,0,tmpscr);
22776 3 walkdown2(COOLSCROLL);
22777 3 }
22778
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 else if(COOLSCROLL)
22779 {
22780 22 openscreen();
22781 22 }
22782 }
22783
22784 188 show_subscreen_life=true;
22785 188 show_subscreen_numbers=true;
22786 188 playLevelMusic();
22787 188 currcset=DMaps[currdmap].color;
22788 188 dointro();
22789 188 set_respawn_point();
22790 188 trySideviewLadder();
22791
22792
2/2
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 188 times.
1316 for(int32_t i=0; i<6; i++)
22793 1128 visited[i]=-1;
22794
22795 188 break;
22796 }
22797
22798 case wtSCROLL: // scrolling warp
22799 {
22800 124 int32_t c = DMaps[currdmap].color;
22801 124 scrolling_map = currmap;
22802 124 currmap = DMaps[wdmap].map;
22803 124 update_subscreens(wdmap);
22804
22805 124 dlevel = DMaps[wdmap].level;
22806 //check if Hero has the map for the new location before updating the subscreen. ? -Z
22807 //This works only in one direction, if Hero had a map, to not having one.
22808 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
22809 124 update_subscreens(wdmap);
22810
22811 /*if ( has_item(itype_map, dlevel) )
22812 {
22813 //Blank the map during an intra-dmap scrolling warp.
22814 dlevel = -1; //a hack for the minimap. This works!! -Z
22815 }*/
22816
22817 // fix the scrolling direction, if it was a tile or instant warp
22818
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(type==0 || type>=3)
22819 {
22820 sdir = dir;
22821 }
22822
22823 124 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
22824 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
22825
22826 124 reset_hookshot();
22827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(reposition_sword_postwarp)
22828 {
22829 weapon *swd=NULL;
22830 for(int32_t i=0; i<Lwpns.Count(); i++)
22831 {
22832 swd = (weapon*)Lwpns.spr(i);
22833
22834 if(swd->id == (attack==wSword ? wSword : wWand))
22835 {
22836 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22837 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22838 positionSword(swd,item_id);
22839 break;
22840 }
22841 }
22842 }
22843
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 110 times.
124 if(!intradmap)
22844 {
22845 110 homescr = currscr = wscr + DMaps[wdmap].xoff;
22846 110 init_dmap();
22847
22848 int32_t wrx,wry;
22849
22850
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 14 times.
110 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22851 {
22852 96 wrx=tmpscr->warpreturnx[0];
22853 96 wry=tmpscr->warpreturny[0];
22854 96 }
22855 else
22856 {
22857 14 wrx=tmpscr->warparrivalx;
22858 14 wry=tmpscr->warparrivaly;
22859 }
22860
22861
7/8
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 10 times.
110 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22862 {
22863
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7 times.
10 if(dlevel)
22864 {
22865 3 lastentrance = currscr;
22866 3 }
22867 else
22868 {
22869 7 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22870 }
22871
22872 10 lastentrance_dmap = wdmap;
22873 10 }
22874 110 }
22875
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 92 times.
124 if(DMaps[currdmap].color != c)
22876 {
22877 92 lighting(false, true);
22878 92 }
22879
22880 124 playLevelMusic();
22881 124 currcset=DMaps[currdmap].color;
22882 124 dointro();
22883 }
22884 124 break;
22885
22886 case wtWHISTLE: // whistle warp
22887 {
22888 20 scrolling_map = currmap;
22889 20 currmap = DMaps[wdmap].map;
22890 20 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
22891 20 reset_hookshot();
22892 20 currdmap=wdmap;
22893 20 dlevel=DMaps[currdmap].level;
22894 20 lighting(false, true);
22895 20 init_dmap();
22896
22897 20 playLevelMusic();
22898 20 currcset=DMaps[currdmap].color;
22899 20 dointro();
22900 20 action=inwind; FFCore.setHeroAction(inwind);
22901 int32_t wry;
22902
22903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22904 wry=tmpscr->warpreturny[0];
22905 20 else wry=tmpscr->warparrivaly;
22906
22907 int32_t wrx;
22908
22909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22910 wrx=tmpscr->warpreturnx[0];
22911 20 else wrx=tmpscr->warparrivalx;
22912
22913
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
40 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
22914
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
22915 20 whirlwind=255;
22916 20 whistleitem=-1;
22917 }
22918 20 break;
22919
22920 case wtIWARP:
22921 case wtIWARPBLK:
22922 case wtIWARPOPEN:
22923 case wtIWARPZAP:
22924 case wtIWARPWAVE: // insta-warps
22925 {
22926 223 bool old_192 = false;
22927
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if (get_bit(quest_rules,qr_192b163_WARP))
22928 {
22929 if ( wtype == wtIWARPWAVE )
22930 {
22931 wtype = wtIWARPWAVE;
22932 old_192 = true;
22933 }
22934 if ( old_192 )
22935 {
22936 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
22937 didpit=false;
22938 update_subscreens();
22939 warp_sound = 0;
22940 is_warping = false;
22941 return false;
22942 }
22943 }
22944 //for determining whether to exit cave
22945 223 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
22946 223 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22947 223 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
22948
22949
8/8
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 212 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 208 times.
439 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
22950
7/8
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 208 times.
✓ Branch 6 taken 205 times.
✓ Branch 7 taken 3 times.
212 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
22951
22952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
239 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
22953 {
22954 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
22955 217 bool wasswimming = (action == swimming);
22956 217 int32_t olddiveclk = diveclk;
22957 217 ALLOFF();
22958
22959
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 6 times.
217 if(wasswimming)
22960 {
22961 6 Hero.SetSwim();
22962 6 diveclk = olddiveclk;
22963 6 }
22964
22965 217 kill_sfx();
22966 217 }
22967 //play sound
22968
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 42 times.
217 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22969
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 205 times.
217 if(wtype==wtIWARPZAP)
22970 {
22971 12 zapout();
22972 12 }
22973
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 182 times.
205 else if(wtype==wtIWARPWAVE)
22974 {
22975 //only draw Hero if he's not in a cave -DD
22976 23 wavyout(!cavewarp);
22977 23 }
22978
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 81 times.
182 else if(wtype!=wtIWARP)
22979 {
22980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 bool b2 = COOLSCROLL&&cavewarp;
22981 81 blackscr(30,b2?false:true);
22982 81 }
22983
22984 217 int32_t c = DMaps[currdmap].color;
22985 217 bool changedlevel = false;
22986 217 bool changeddmap = false;
22987
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 192 times.
217 if(currdmap != wdmap)
22988 {
22989 192 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22990 192 changeddmap = true;
22991 192 }
22992
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 60 times.
217 if(dlevel != DMaps[wdmap].level)
22993 {
22994 60 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22995 60 changedlevel = true;
22996 60 }
22997 217 dlevel = DMaps[wdmap].level;
22998 217 currdmap = wdmap;
22999
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 192 times.
217 if(changeddmap)
23000 {
23001 192 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23002 192 }
23003
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 60 times.
217 if(changedlevel)
23004 {
23005 60 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23006 60 }
23007
23008 217 currmap = DMaps[currdmap].map;
23009 217 init_dmap();
23010 217 update_subscreens(wdmap);
23011
23012 217 ringcolor(false);
23013
23014
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 147 times.
217 if(DMaps[currdmap].color != c)
23015 147 loadlvlpal(DMaps[currdmap].color);
23016
23017 217 homescr = currscr = wscr + DMaps[currdmap].xoff;
23018
23019 217 lightingInstant(); // Also sets naturaldark
23020
23021 217 loadscr(0,currdmap,currscr,-1,overlay);
23022
23023 217 x = tmpscr->warpreturnx[wrindex];
23024 217 y = tmpscr->warpreturny[wrindex];
23025
23026
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 36 times.
217 if(didpit)
23027 {
23028 36 didpit=false;
23029 36 x=pitx;
23030 36 y=pity;
23031 36 }
23032
23033 217 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23034 217 type2 = combobuf[MAPCOMBO(x,y)].type;
23035 217 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23036
23037
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 2 times.
217 if(x==0) dir=right;
23038
23039
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(x==240) dir=left;
23040
23041
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 2 times.
217 if(y==0) dir=down;
23042
23043
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 14 times.
217 if(y==160) dir=up;
23044
23045 217 markBmap(dir^1);
23046
23047 217 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
23048
23049
10/16
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✓ Branch 15 taken 212 times.
222 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23050 {
23051 5 hopclk=0xFF;
23052 5 SetSwim();
23053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!IsSideSwim()) attackclk = charging = spins = 0;
23054 5 }
23055 else
23056 {
23057 212 action = none; FFCore.setHeroAction(none);
23058 }
23059 //preloaded freeform combos
23060 217 ffscript_engine(true);
23061
23062 217 putscr(scrollbuf,0,0,tmpscr);
23063 217 putscrdoors(scrollbuf,0,0,tmpscr);
23064
23065
10/10
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 215 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 213 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 8 times.
217 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23066 {
23067 14 reset_pal_cycling();
23068 14 putscr(scrollbuf,0,0,tmpscr);
23069 14 putscrdoors(scrollbuf,0,0,tmpscr);
23070 14 walkup(COOLSCROLL);
23071 14 }
23072
7/10
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 215 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 215 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
221 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23073 {
23074 12 reset_pal_cycling();
23075 12 putscr(scrollbuf,0,0,tmpscr);
23076 12 putscrdoors(scrollbuf,0,0,tmpscr);
23077 12 walkdown2(COOLSCROLL);
23078 12 }
23079
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 203 times.
215 else if(wtype==wtIWARPZAP)
23080 {
23081 12 zapin();
23082 12 }
23083
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 180 times.
203 else if(wtype==wtIWARPWAVE)
23084 {
23085 23 wavyin();
23086 23 }
23087
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 9 times.
180 else if(wtype==wtIWARPOPEN)
23088 {
23089 9 openscreen();
23090 9 }
23091
1/2
✓ Branch 0 taken 229 times.
✗ Branch 1 not taken.
229 if(reposition_sword_postwarp)
23092 {
23093 weapon *swd=NULL;
23094 for(int32_t i=0; i<Lwpns.Count(); i++)
23095 {
23096 swd = (weapon*)Lwpns.spr(i);
23097
23098 if(swd->id == (attack==wSword ? wSword : wWand))
23099 {
23100 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23101 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23102 positionSword(swd,item_id);
23103 break;
23104 }
23105 }
23106 }
23107 229 show_subscreen_life=true;
23108 229 show_subscreen_numbers=true;
23109 229 playLevelMusic();
23110 229 currcset=DMaps[currdmap].color;
23111 229 dointro();
23112 229 set_respawn_point();
23113 229 trySideviewLadder();
23114 }
23115 229 break;
23116
23117
23118 case wtNOWARP:
23119 {
23120 37 bool old_192 = false;
23121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if (get_bit(quest_rules,qr_192b163_WARP))
23122 {
23123 wtype = wtIWARPWAVE;
23124 old_192 = true;
23125 }
23126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if ( old_192 )
23127 {
23128 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
23129 //for determining whether to exit cave
23130 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23131 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23132 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23133
23134 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
23135 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
23136
23137 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
23138 {
23139 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23140 bool wasswimming = (action == swimming);
23141 int32_t olddiveclk = diveclk;
23142 ALLOFF();
23143
23144 if(wasswimming)
23145 {
23146 Hero.SetSwim();
23147 diveclk = olddiveclk;
23148 }
23149
23150 kill_sfx();
23151 }
23152 //play sound
23153 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23154 if(wtype==wtIWARPZAP)
23155 {
23156 zapout();
23157 }
23158 else if(wtype==wtIWARPWAVE)
23159 {
23160 //only draw Hero if he's not in a cave -DD
23161 wavyout(!cavewarp);
23162 }
23163 else if(wtype!=wtIWARP)
23164 {
23165 bool b2 = COOLSCROLL&&cavewarp;
23166 blackscr(30,b2?false:true);
23167 }
23168
23169 int32_t c = DMaps[currdmap].color;
23170 bool changedlevel = false;
23171 bool changeddmap = false;
23172 if(currdmap != wdmap)
23173 {
23174 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23175 changeddmap = true;
23176 }
23177 if(dlevel != DMaps[wdmap].level)
23178 {
23179 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23180 changedlevel = true;
23181 }
23182 dlevel = DMaps[wdmap].level;
23183 currdmap = wdmap;
23184 if(changeddmap)
23185 {
23186 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23187 }
23188 if(changedlevel)
23189 {
23190 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23191 }
23192 currmap = DMaps[currdmap].map;
23193 init_dmap();
23194 update_subscreens(wdmap);
23195
23196 ringcolor(false);
23197
23198 if(DMaps[currdmap].color != c)
23199 loadlvlpal(DMaps[currdmap].color);
23200
23201 homescr = currscr = wscr + DMaps[currdmap].xoff;
23202
23203 lightingInstant(); // Also sets naturaldark
23204
23205 loadscr(0,currdmap,currscr,-1,overlay);
23206
23207 x = tmpscr->warpreturnx[wrindex];
23208 y = tmpscr->warpreturny[wrindex];
23209
23210 if(didpit)
23211 {
23212 didpit=false;
23213 x=pitx;
23214 y=pity;
23215 }
23216
23217 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23218 type2 = combobuf[MAPCOMBO(x,y)].type;
23219 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23220
23221 if(x==0) dir=right;
23222
23223 if(x==240) dir=left;
23224
23225 if(y==0) dir=down;
23226
23227 if(y==160) dir=up;
23228
23229 markBmap(dir^1);
23230
23231 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
23232 {
23233 hopclk=0xFF;
23234 SetSwim();
23235 if (!IsSideSwim()) attackclk = charging = spins = 0;
23236 }
23237 else
23238 {
23239 action = none;
23240 FFCore.setHeroAction(none);
23241 }
23242 //preloaded freeform combos
23243 ffscript_engine(true);
23244
23245 putscr(scrollbuf,0,0,tmpscr);
23246 putscrdoors(scrollbuf,0,0,tmpscr);
23247
23248 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23249 {
23250 reset_pal_cycling();
23251 putscr(scrollbuf,0,0,tmpscr);
23252 putscrdoors(scrollbuf,0,0,tmpscr);
23253 walkup(COOLSCROLL);
23254 }
23255 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23256 {
23257 reset_pal_cycling();
23258 putscr(scrollbuf,0,0,tmpscr);
23259 putscrdoors(scrollbuf,0,0,tmpscr);
23260 walkdown2(COOLSCROLL);
23261 }
23262 else if(wtype==wtIWARPZAP)
23263 {
23264 zapin();
23265 }
23266 else if(wtype==wtIWARPWAVE)
23267 {
23268 wavyin();
23269 }
23270 else if(wtype==wtIWARPOPEN)
23271 {
23272 openscreen();
23273 }
23274 if(reposition_sword_postwarp)
23275 {
23276 weapon *swd=NULL;
23277 for(int32_t i=0; i<Lwpns.Count(); i++)
23278 {
23279 swd = (weapon*)Lwpns.spr(i);
23280
23281 if(swd->id == (attack==wSword ? wSword : wWand))
23282 {
23283 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23284 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23285 positionSword(swd,item_id);
23286 break;
23287 }
23288 }
23289 }
23290 show_subscreen_life=true;
23291 show_subscreen_numbers=true;
23292 playLevelMusic();
23293 currcset=DMaps[currdmap].color;
23294 dointro();
23295 set_respawn_point();
23296 trySideviewLadder();
23297 break;
23298 }
23299 else
23300 {
23301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(reposition_sword_postwarp)
23302 {
23303 weapon *swd=NULL;
23304 for(int32_t i=0; i<Lwpns.Count(); i++)
23305 {
23306 swd = (weapon*)Lwpns.spr(i);
23307
23308 if(swd->id == (attack==wSword ? wSword : wWand))
23309 {
23310 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23311 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23312 positionSword(swd,item_id);
23313 break;
23314 }
23315 }
23316 }
23317 37 didpit=false;
23318 37 update_subscreens();
23319 37 warp_sound = 0;
23320 37 is_warping = false;
23321 37 return false;
23322 }
23323 }
23324 default:
23325 didpit=false;
23326 update_subscreens();
23327 warp_sound = 0;
23328 is_warping = false;
23329 if(reposition_sword_postwarp)
23330 {
23331 weapon *swd=NULL;
23332 for(int32_t i=0; i<Lwpns.Count(); i++)
23333 {
23334 swd = (weapon*)Lwpns.spr(i);
23335
23336 if(swd->id == (attack==wSword ? wSword : wWand))
23337 {
23338 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23339 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23340 positionSword(swd,item_id);
23341 break;
23342 }
23343 }
23344 }
23345 return false;
23346 }
23347
23348
23349
23350 // Stop Hero from drowning!
23351
5/6
✓ Branch 0 taken 1057 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1057 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1045 times.
1069 if(action==drowning || action==lavadrowning || action==sidedrowning)
23352 {
23353 24 drownclk=0;
23354 24 drownclk=0;
23355 24 action=none; FFCore.setHeroAction(none);
23356 24 }
23357
23358 1045 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
23359 // But keep him swimming if he ought to be!
23360 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
23361
9/12
✓ Branch 0 taken 1054 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1039 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 1057 times.
✓ Branch 11 taken 6 times.
1060 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
23362 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
23363
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
15 && (action!=inwind))
23364 {
23365 6 hopclk=0xFF;
23366 6 SetSwim();
23367 6 }
23368
23369 1063 newscr_clk=frame;
23370 1063 activated_timed_warp=false;
23371 1063 eat_buttons();
23372
23373
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 956 times.
1063 if(wtype!=wtIWARP)
23374 956 attackclk=0;
23375
23376 1063 didstuff=0;
23377 1063 usecounts.clear();
23378 1063 map_bkgsfx(true);
23379 1063 loadside=dir^1;
23380 1063 whistleclk=-1;
23381
23382
3/4
✓ Branch 0 taken 1057 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1063 times.
✗ Branch 3 not taken.
1063 if((z>0 || fakez>0) && isSideViewHero())
23383 {
23384 y-=z;
23385 y-=fakez;
23386 fakez=0;
23387 z=0;
23388 }
23389
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 941 times.
1063 else if(!isSideViewHero())
23390 {
23391 941 fall=0;
23392 941 fakefall=0;
23393 941 }
23394
23395 // If warping between top-down and sideview screens,
23396 // fix enemies that are carried over by Full Screen Warp
23397 1063 const bool tmpscr_is_sideview = isSideViewHero();
23398
23399
4/4
✓ Branch 0 taken 944 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 914 times.
✓ Branch 3 taken 30 times.
1063 if(!wasSideview && tmpscr_is_sideview)
23400 {
23401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 for(int32_t i=0; i<guys.Count(); i++)
23402 {
23403 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
23404 {
23405 guys.spr(i)->y -= guys.spr(i)->z;
23406 guys.spr(i)->y -= guys.spr(i)->fakez;
23407 guys.spr(i)->z = 0;
23408 guys.spr(i)->fakez = 0;
23409 }
23410
23411 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23412 guys.spr(i)->yofs += 2;
23413 }
23414 30 }
23415
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 920 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 27 times.
1033 else if(wasSideview && !tmpscr_is_sideview)
23416 {
23417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
23418 {
23419 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23420 guys.spr(i)->yofs -= 2;
23421 }
23422 27 }
23423
23424
6/6
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 343 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 570 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 8 times.
1063 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
23425 {
23426
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 365 times.
485 if(dlevel)
23427 {
23428 int32_t wrx,wry;
23429
23430
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23431 {
23432 27 wrx=tmpscr->warpreturnx[0];
23433 27 wry=tmpscr->warpreturny[0];
23434 27 }
23435 else
23436 {
23437 93 wrx=tmpscr->warparrivalx;
23438 93 wry=tmpscr->warparrivaly;
23439 }
23440
23441
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
120 if((wtype == wtEXIT)
23442
5/10
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
120 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
23443 {
23444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
23445 {
23446 35 game->set_continue_scrn(homescr);
23447 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
23448 35 }
23449 else if(currdmap != game->get_continue_dmap())
23450 {
23451 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23452 }
23453 35 }
23454 else
23455 {
23456
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 3 times.
85 if(currdmap != game->get_continue_dmap())
23457 {
23458 3 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23459 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
23460 3 }
23461 }
23462 120 }
23463 else
23464 {
23465 365 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23466 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
23467 }
23468
23469 485 game->set_continue_dmap(currdmap);
23470 485 lastentrance_dmap = currdmap;
23471 485 lastentrance = game->get_continue_scrn();
23472 //Z_message("continue_map = %d\n",game->get_continue_dmap());
23473 485 }
23474
23475
1/2
✓ Branch 0 taken 1063 times.
✗ Branch 1 not taken.
1063 if(tmpscr->flags4&fAUTOSAVE)
23476 {
23477 save_game(true,0);
23478 }
23479
23480
2/2
✓ Branch 0 taken 1051 times.
✓ Branch 1 taken 12 times.
1063 if(tmpscr->flags6&fCONTINUEHERE)
23481 {
23482 12 lastentrance_dmap = currdmap;
23483 12 lastentrance = homescr;
23484 12 }
23485
23486 1063 update_subscreens();
23487 1063 verifyBothWeapons();
23488
23489
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 338 times.
1063 if(wtype==wtCAVE)
23490 {
23491
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 97 times.
338 if(DMaps[currdmap].flags&dmfGUYCAVES)
23492 482 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
23493 241 (char *)moduledata.roomtype_names[tmpscr[1].room]);
23494 else
23495 97 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
23496 338 }
23497 1450 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
23498
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 549 times.
1274 wtype==wtPASS ? "Passageway" :
23499
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 361 times.
910 wtype==wtEXIT ? "Entrance/Exit" :
23500
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 237 times.
361 wtype==wtSCROLL ? "Scrolling Warp" :
23501 237 wtype==wtWHISTLE ? "Whistle Warp" :
23502 "Insta-Warp");
23503
23504 1063 eventlog_mapflags();
23505
1/2
✓ Branch 0 taken 1063 times.
✗ Branch 1 not taken.
1063 if(reposition_sword_postwarp)
23506 {
23507 weapon *swd=NULL;
23508 for(int32_t i=0; i<Lwpns.Count(); i++)
23509 {
23510 swd = (weapon*)Lwpns.spr(i);
23511
23512 if(swd->id == (attack==wSword ? wSword : wWand))
23513 {
23514 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23515 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23516 positionSword(swd,item_id);
23517 break;
23518 }
23519 }
23520 }
23521 1063 FFCore.init_combo_doscript();
23522
4/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 454 times.
✓ Branch 3 taken 6 times.
1063 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
23523 {
23524 1057 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
23525 1057 FFCore.initZScriptDMapScripts();
23526 1057 FFCore.initZScriptActiveSubscreenScript();
23527 1057 }
23528 1063 is_warping = false;
23529 1063 return true;
23530 1100 }
23531
23532 187 void HeroClass::exitcave()
23533 {
23534 187 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23535 187 currscr=homescr;
23536 187 loadscr(0,currdmap,currscr,255,false); // bogus direction
23537 187 x = tmpscr->warpreturnx[0];
23538 187 y = tmpscr->warpreturny[0];
23539
23540
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(didpit)
23541 {
23542 didpit=false;
23543 x=pitx;
23544 y=pity;
23545 }
23546
23547
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 11 times.
187 if(x+y == 0)
23548 11 x = y = 80;
23549
23550 187 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23551 187 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23552 187 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23553
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 170 times.
377 bool b = COOLSCROLL &&
23554
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 141 times.
170 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
23555
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 141 times.
141 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
23556
4/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 123 times.
141 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
23557
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 5 times.
123 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
23558 207 ALLOFF();
23559 207 blackscr(30,b?false:true);
23560 207 ringcolor(false);
23561 207 loadlvlpal(DMaps[currdmap].color);
23562 207 lighting(false, true);
23563 207 music_stop();
23564 207 kill_sfx();
23565 207 putscr(scrollbuf,0,0,tmpscr);
23566 207 putscrdoors(scrollbuf,0,0,tmpscr);
23567
23568
9/10
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 161 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 156 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
207 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23569 {
23570 56 walkup(COOLSCROLL);
23571 56 }
23572
9/10
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 138 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 138 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
161 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23573 {
23574 18 walkdown2(COOLSCROLL);
23575 18 }
23576
23577 217 show_subscreen_life=true;
23578 217 show_subscreen_numbers=true;
23579 217 playLevelMusic();
23580 217 currcset=DMaps[currdmap].color;
23581 217 dointro();
23582 217 newscr_clk=frame;
23583 217 activated_timed_warp=false;
23584 217 dir=down;
23585 217 set_respawn_point();
23586 217 eat_buttons();
23587 217 didstuff=0;
23588 217 usecounts.clear();
23589 217 map_bkgsfx(true);
23590 217 loadside=dir^1;
23591 217 }
23592
23593
23594 3258 void HeroClass::stepforward(int32_t steps, bool adjust)
23595 {
23596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if ( FFCore.nostepforward ) return;
23597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
23598 3258 zfix tx=x; //temp x
23599 3258 zfix ty=y; //temp y
23600 3258 zfix tstep(0); //temp single step distance
23601 3258 zfix s(0); //calculated step distance for all steps
23602 3258 z3step=2;
23603 3258 int32_t sh=shiftdir;
23604 3258 shiftdir=-1;
23605
23606
2/2
✓ Branch 0 taken 55601 times.
✓ Branch 1 taken 3258 times.
58859 for(int32_t i=steps; i>0; --i)
23607 {
23608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55601 times.
55601 if(diagonalMovement)
23609 {
23610 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23611 {
23612 tstep = 1.5;
23613 }
23614 else
23615 {
23616 tstep=z3step;
23617 z3step=(z3step%2)+1;
23618 }
23619 }
23620 else
23621 {
23622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55601 times.
55601 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
23623 {
23624 tstep = 1.5;
23625 }
23626 else
23627 {
23628
2/2
✓ Branch 0 taken 32626 times.
✓ Branch 1 taken 22975 times.
55601 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
23629
23630
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18128 times.
✓ Branch 2 taken 14498 times.
✓ Branch 3 taken 10205 times.
✓ Branch 4 taken 12770 times.
55601 switch(dir)
23631 {
23632 case up:
23633 18128 ty-=tstep;
23634 18128 break;
23635
23636 case down:
23637 14498 ty+=tstep;
23638 14498 break;
23639
23640 case left:
23641 10205 tx-=tstep;
23642 10205 break;
23643
23644 case right:
23645 12770 tx+=tstep;
23646 12770 break;
23647 }
23648 }
23649 }
23650
23651 55601 s+=tstep;
23652 55601 }
23653
23654 3258 z3step=2;
23655
23656 3258 x = x.getInt();
23657 3258 y = y.getInt();
23658
2/2
✓ Branch 0 taken 58788 times.
✓ Branch 1 taken 3258 times.
62046 while(s>=0)
23659 {
23660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58788 times.
58788 if(diagonalMovement)
23661 {
23662 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23663 {
23664 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23665 {
23666 walkable = false;
23667 shiftdir = -1;
23668 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23669 switch(tdir)
23670 {
23671 case left:
23672 --x;
23673 break;
23674 case right:
23675 ++x;
23676 break;
23677 case up:
23678 --y;
23679 break;
23680 case down:
23681 ++y;
23682 break;
23683 }
23684 }
23685 else
23686 {
23687 walkable=false;
23688 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23689 move(dir, 150);
23690 }
23691 }
23692 else
23693 {
23694 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23695 {
23696 s-=1.5;
23697 }
23698 else
23699 {
23700 s-=z3step;
23701 }
23702 walkable=true;
23703 move(dir, 150);
23704 }
23705
23706 shiftdir=-1;
23707 }
23708 else
23709 {
23710
3/6
✓ Branch 0 taken 34562 times.
✓ Branch 1 taken 24226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58788 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58788 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23711 {
23712 walkable=false;
23713 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23714 switch(tdir)
23715 {
23716 case left:
23717 --x;
23718 break;
23719 case right:
23720 ++x;
23721 break;
23722 case up:
23723 --y;
23724 break;
23725 case down:
23726 ++y;
23727 break;
23728 }
23729 }
23730 else
23731 {
23732
2/4
✓ Branch 0 taken 58788 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58788 times.
58788 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23733 {
23734 s-=1.5;
23735 }
23736
2/2
✓ Branch 0 taken 34562 times.
✓ Branch 1 taken 24226 times.
58788 else if(dir<left)
23737 {
23738 34562 s-=lsteps[y.getInt()&7];
23739 34562 }
23740 else
23741 {
23742 24226 s-=lsteps[x.getInt()&7];
23743 }
23744
23745 58788 move(dir, 150);
23746 }
23747 }
23748
23749
2/2
✓ Branch 0 taken 55530 times.
✓ Branch 1 taken 3258 times.
58788 if(s<0)
23750 {
23751 // Not quite sure how this is actually supposed to work.
23752 // There have to be two cases for each direction or Hero
23753 // either walks too far onto the screen or may get stuck
23754 // going through walk-through walls.
23755
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1246 times.
✓ Branch 2 taken 760 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 710 times.
3258 switch(dir)
23756 {
23757 case up:
23758
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1176 times.
1246 if(y<8) // Leaving the screen
23759 70 y+=s;
23760 else // Entering the screen
23761 1176 y-=s;
23762
23763 1246 break;
23764
23765 case down:
23766
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 696 times.
760 if(y>152)
23767 64 y-=s;
23768 else
23769 696 y+=s;
23770
23771 760 break;
23772
23773 case left:
23774
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 493 times.
542 if(x<8)
23775 49 x+=s;
23776 else
23777 493 x-=s;
23778
23779 542 break;
23780
23781 case right:
23782
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 652 times.
710 if(x>=232)
23783 58 x-=s;
23784 else
23785 652 x+=s;
23786
23787 710 break;
23788 }
23789 3258 }
23790
23791
23792 58788 draw_screen(tmpscr);
23793
1/2
✓ Branch 0 taken 58788 times.
✗ Branch 1 not taken.
58788 if (canSideviewLadder()) setOnSideviewLadder(true);
23794 58788 advanceframe(true);
23795
23796
1/2
✓ Branch 0 taken 58788 times.
✗ Branch 1 not taken.
58788 if(Quit)
23797 return;
23798 }
23799
4/4
✓ Branch 0 taken 2548 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 760 times.
✓ Branch 3 taken 1788 times.
3258 if(dir==right||dir==down)
23800 {
23801 1470 x=int32_t(x);
23802 1470 y=int32_t(y);
23803 1470 }
23804 else
23805 {
23806 1788 x = x.getInt();
23807 1788 y = y.getInt();
23808 }
23809 3258 set_respawn_point();
23810 3258 draw_screen(tmpscr);
23811 3258 eat_buttons();
23812 3258 shiftdir=sh;
23813 3258 }
23814
23815 142 void HeroClass::walkdown(bool opening) //entering cave
23816 {
23817
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 113 times.
142 if(opening)
23818 {
23819 113 close_black_opening(x+8, y+8+playing_field_offset, false);
23820 113 }
23821
23822 142 hclk=0;
23823 142 stop_item_sfx(itype_brang);
23824 142 sfx(WAV_STAIRS,pan(x.getInt()));
23825 142 clk=0;
23826 // int32_t cmby=(y.getInt()&0xF0)+16;
23827 // Fix Hero's position to the grid
23828 142 y=y.getInt()&0xF0;
23829 142 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23830 142 attack=wNone;
23831 142 attackid=-1;
23832 142 reset_swordcharge();
23833 142 climb_cover_x=x.getInt()&0xF0;
23834 142 climb_cover_y=(y.getInt()&0xF0)+16;
23835
23836 142 guys.clear();
23837 142 chainlinks.clear();
23838 142 Lwpns.clear();
23839 142 Ewpns.clear();
23840 142 items.clear();
23841
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 9088 times.
9230 for(int32_t i=0; i<64; i++)
23842 {
23843 9088 herostep();
23844
23845
2/4
✓ Branch 0 taken 9088 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9088 times.
9088 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23846 hero_count=(hero_count+1)%16;
23847
23848
2/2
✓ Branch 0 taken 6816 times.
✓ Branch 1 taken 2272 times.
9088 if((i&3)==3)
23849 2272 ++y;
23850
23851 9088 draw_screen(tmpscr);
23852 9088 advanceframe(true);
23853
23854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9088 times.
9088 if(Quit)
23855 break;
23856 9088 }
23857
23858 142 action=none; FFCore.setHeroAction(none);
23859 142 }
23860
23861 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
23862 {
23863 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23864
23865
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
23866 y-=16;
23867
23868 21 dir=down;
23869 // Fix Hero's position to the grid
23870 21 y=y.getInt()&0xF0;
23871 21 z=fakez=fall=fakefall=0;
23872
23873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
23874 {
23875 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
23876 21 }
23877
23878 21 hclk=0;
23879 21 stop_item_sfx(itype_brang);
23880 21 sfx(WAV_STAIRS,pan(x.getInt()));
23881 21 clk=0;
23882 // int32_t cmby=y.getInt()&0xF0;
23883 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23884 21 attack=wNone;
23885 21 attackid=-1;
23886 21 reset_swordcharge();
23887 21 climb_cover_x=x.getInt()&0xF0;
23888 21 climb_cover_y=y.getInt()&0xF0;
23889
23890 21 guys.clear();
23891 21 chainlinks.clear();
23892 21 Lwpns.clear();
23893 21 Ewpns.clear();
23894 21 items.clear();
23895
23896
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
23897 {
23898 1344 herostep();
23899
23900
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23901 hero_count=(hero_count+1)%16;
23902
23903
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
23904 336 ++y;
23905
23906 1344 draw_screen(tmpscr);
23907 1344 advanceframe(true);
23908
23909
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
23910 break;
23911 1344 }
23912
23913 21 action=none; FFCore.setHeroAction(none);
23914 21 }
23915
23916 111 void HeroClass::walkup(bool opening) //exiting cave
23917 {
23918 111 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23919
23920
4/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 107 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
111 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
23921 y+=16;
23922
23923 // Fix Hero's position to the grid
23924 111 y=y.getInt()&0xF0;
23925 111 z=fakez=fall=fakefall=0;
23926
23927
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 89 times.
111 if(opening)
23928 {
23929 89 open_black_opening(x+8, y+8+playing_field_offset-16, false);
23930 89 }
23931
23932 111 hclk=0;
23933 111 stop_item_sfx(itype_brang);
23934 111 sfx(WAV_STAIRS,pan(x.getInt()));
23935 111 dir=down;
23936 111 clk=0;
23937 // int32_t cmby=y.getInt()&0xF0;
23938 111 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23939 111 attack=wNone;
23940 111 attackid=-1;
23941 111 reset_swordcharge();
23942 111 climb_cover_x=x.getInt()&0xF0;
23943 111 climb_cover_y=y.getInt()&0xF0;
23944
23945 111 guys.clear();
23946 111 chainlinks.clear();
23947 111 Lwpns.clear();
23948 111 Ewpns.clear();
23949 111 items.clear();
23950
23951
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 7104 times.
7215 for(int32_t i=0; i<64; i++)
23952 {
23953 7104 herostep();
23954
23955
2/4
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7104 times.
7104 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23956 hero_count=(hero_count+1)%16;
23957
23958
2/2
✓ Branch 0 taken 5328 times.
✓ Branch 1 taken 1776 times.
7104 if((i&3)==0)
23959 1776 --y;
23960
23961 7104 draw_screen(tmpscr);
23962 7104 advanceframe(true);
23963
23964
1/2
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
7104 if(Quit)
23965 break;
23966 7104 }
23967 111 map_bkgsfx(true);
23968 111 loadside=dir^1;
23969 111 action=none; FFCore.setHeroAction(none);
23970 111 }
23971
23972 27 void HeroClass::walkup2(bool opening) //entering cave2
23973 {
23974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(opening)
23975 {
23976 27 close_black_opening(x+8, y+8+playing_field_offset, false);
23977 27 }
23978
23979 27 hclk=0;
23980 27 stop_item_sfx(itype_brang);
23981 27 sfx(WAV_STAIRS,pan(x.getInt()));
23982 27 dir=up;
23983 27 clk=0;
23984 // int32_t cmby=y.getInt()&0xF0;
23985 27 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23986 27 attack=wNone;
23987 27 attackid=-1;
23988 27 reset_swordcharge();
23989 27 climb_cover_x=x.getInt()&0xF0;
23990 27 climb_cover_y=(y.getInt()&0xF0)-16;
23991
23992 27 guys.clear();
23993 27 chainlinks.clear();
23994 27 Lwpns.clear();
23995 27 Ewpns.clear();
23996 27 items.clear();
23997
23998
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1728 times.
1755 for(int32_t i=0; i<64; i++)
23999 {
24000 1728 herostep();
24001
24002
2/4
✓ Branch 0 taken 1728 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1728 times.
1728 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24003 hero_count=(hero_count+1)%16;
24004
24005
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 432 times.
1728 if((i&3)==0)
24006 432 --y;
24007
24008 1728 draw_screen(tmpscr);
24009 1728 advanceframe(true);
24010
24011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1728 times.
1728 if(Quit)
24012 break;
24013 1728 }
24014 27 map_bkgsfx(true);
24015 27 loadside=dir^1;
24016 27 action=none; FFCore.setHeroAction(none);
24017 27 }
24018
24019 253 void HeroClass::stepout() // Step out of item cellars and passageways
24020 {
24021 253 int32_t sc = specialcave; // This gets erased by ALLOFF()
24022 253 ALLOFF();
24023 253 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
24024 253 map_bkgsfx(false);
24025 253 kill_enemy_sfx();
24026 253 draw_screen(tmpscr,false);
24027 253 fade(sc>=GUYCAVE?10:11,true,false);
24028 253 blackscr(30,true);
24029 253 ringcolor(false);
24030
24031
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 169 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 129 times.
253 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
24032 {
24033 129 currdmap=stepoutdmap;
24034 129 currmap=DMaps[currdmap].map;
24035 129 dlevel=DMaps[currdmap].level;
24036
24037 //we might have just left a passage, so be sure to update the CSet record -DD
24038 129 currcset=DMaps[currdmap].color;
24039
24040 129 init_dmap();
24041 129 homescr=stepoutscr;
24042 129 }
24043
24044 253 currscr=homescr;
24045 253 loadscr(0,currdmap,currscr,255,false); // bogus direction
24046 253 draw_screen(tmpscr,false);
24047
24048
3/4
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 3 times.
253 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
24049 {
24050 250 darkroom = naturaldark = false;
24051 250 fade(DMaps[currdmap].color,true,true);
24052 250 }
24053 else
24054 {
24055 3 darkroom = naturaldark = true;
24056
24057
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(get_bit(quest_rules,qr_FADE))
24058 {
24059 1 interpolatedfade();
24060 1 }
24061 else
24062 {
24063 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24064 }
24065 3 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
24066 3 si+=3*48;
24067
24068
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 for(int32_t i=0; i<16; i++)
24069 {
24070 48 RAMpal[CSET(9)+i] = _RGB(si);
24071 48 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
24072 48 si+=3;
24073 48 }
24074 }
24075
24076 253 x = tmpscr->warpreturnx[stepoutwr];
24077 253 y = tmpscr->warpreturny[stepoutwr];
24078
24079
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(didpit)
24080 {
24081 didpit=false;
24082 x=pitx;
24083 y=pity;
24084 }
24085
24086
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 247 times.
253 if(x+y == 0)
24087 6 x = y = 80;
24088
24089 253 dir=down;
24090
24091 253 set_respawn_point();
24092
24093 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
24094 253 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
24095
24096
4/6
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
253 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
24097 {
24098 walkup(false);
24099 }
24100
4/6
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
253 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
24101 {
24102 walkdown2(false);
24103 }
24104
24105 253 newscr_clk=frame;
24106 253 activated_timed_warp=false;
24107 253 didstuff=0;
24108 253 usecounts.clear();
24109 253 eat_buttons();
24110 253 markBmap(-1);
24111 253 map_bkgsfx(true);
24112
24113
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 27 times.
253 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
24114 {
24115 27 music_stop();
24116 27 playLevelMusic();
24117 27 }
24118
1/2
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
226 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
24119 {
24120 playLevelMusic();
24121 }
24122
24123 253 loadside=dir^1;
24124 253 }
24125
24126 7104 bool HeroClass::nextcombo_wf(int32_t d2)
24127 {
24128
6/8
✓ Branch 0 taken 7053 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 6895 times.
✓ Branch 3 taken 158 times.
✓ Branch 4 taken 6895 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 158 times.
✗ Branch 7 not taken.
7104 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
24129 7104 return false;
24130
24131 // assumes Hero is about to scroll screens
24132
24133 int32_t ns = nextscr(d2);
24134
24135 if(ns==0xFFFF)
24136 return false;
24137
24138 // want actual screen index, not game->maps[] index
24139 ns = (ns&127) + (ns>>7)*MAPSCRS;
24140
24141 int32_t cx = x;
24142 int32_t cy = y;
24143
24144 switch(d2)
24145 {
24146 case up:
24147 cy=160;
24148 break;
24149
24150 case down:
24151 cy=0;
24152 break;
24153
24154 case left:
24155 cx=240;
24156 break;
24157
24158 case right:
24159 cx=0;
24160 break;
24161 }
24162
24163 // check lower half of combo
24164 cy += 8;
24165
24166 // from MAPCOMBO()
24167 int32_t cmb = (cy&0xF0)+(cx>>4);
24168
24169 if(cmb>175)
24170 return true;
24171
24172 newcombo c = combobuf[TheMaps[ns].data[cmb]];
24173 bool dried = iswater_type(c.type) && DRIEDLAKE;
24174 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24175 int32_t b=1;
24176
24177 if(cx&8) b<<=2;
24178
24179 if(cy&8) b<<=1;
24180
24181 if((c.walk&b) && !dried && !swim)
24182 return true;
24183
24184 // next block (i.e. cnt==2)
24185 if(!(cx&8))
24186 {
24187 b<<=2;
24188 }
24189 else
24190 {
24191 c = combobuf[TheMaps[ns].data[++cmb]];
24192 dried = iswater_type(c.type) && DRIEDLAKE;
24193 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24194 b=1;
24195
24196 if(cy&8)
24197 {
24198 b<<=1;
24199 }
24200 }
24201
24202 return (c.walk&b) ? !dried && !swim : false;
24203 7104 }
24204
24205 bool HeroClass::nextcombo_solid(int32_t d2)
24206 {
24207 if(toogam || currscr>=128)
24208 return false;
24209
24210 // assumes Hero is about to scroll screens
24211
24212 int32_t ns = nextscr(d2);
24213
24214 if(ns==0xFFFF)
24215 return false;
24216
24217 // want actual screen index, not game->maps[] index
24218 ns = (ns&127) + (ns>>7)*MAPSCRS;
24219 int32_t screen = (ns%MAPSCRS);
24220 int32_t map = (ns - screen) / MAPSCRS;
24221
24222 int32_t cx = x;
24223 int32_t cy = y;
24224
24225 switch(d2)
24226 {
24227 case up:
24228 cy=160;
24229 break;
24230
24231 case down:
24232 cy=0;
24233 break;
24234
24235 case left:
24236 cx=240;
24237 break;
24238
24239 case right:
24240 cx=0;
24241 break;
24242 }
24243
24244 if(d2==up) cy += 8;
24245
24246 if(d2==left||d2==right) cy+=bigHitbox?0:8;
24247
24248 int32_t initcx = cx;
24249 int32_t initcy = cy;
24250 // from MAPCOMBO()
24251
24252 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
24253 {
24254 cx = initcx;
24255 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
24256 {
24257 int32_t cmb = (cy&0xF0)+(cx>>4);
24258
24259 if(cmb>175)
24260 {
24261 return true;
24262 }
24263
24264 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
24265
24266 int32_t b=1;
24267
24268 if(cx&8) b<<=2;
24269
24270 if(cy&8) b<<=1;
24271
24272 //bool bridgedetected = false;
24273
24274 int32_t walk = c.walk;
24275 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
24276 {
24277 for (int32_t m = 0; m <= 1; m++)
24278 {
24279 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
24280 if (cmb.type == cBRIDGE)
24281 {
24282 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
24283 {
24284 int efflag = (cmb.walk & 0xF0)>>4;
24285 int newsolid = (cmb.walk & 0xF);
24286 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
24287 }
24288 else walk &= cmb.walk;
24289 }
24290 else walk |= cmb.walk;
24291 }
24292 }
24293 /*
24294 if (bridgedetected)
24295 {
24296 continue;
24297 }*/
24298
24299 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
24300 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
24301
24302 if((walk&b) && !swim)
24303 {
24304 return true;
24305 }
24306 }
24307
24308 /*
24309 #if 0
24310
24311 //
24312 // next block (i.e. cnt==2)
24313 if(!(cx&8))
24314 {
24315 b<<=2;
24316 }
24317 else
24318 {
24319 c = combobuf[TheMaps[ns].data[++cmb]];
24320 dried = iswater_type(c.type) && DRIEDLAKE;
24321 //swim = iswater_type(c.type) && (current_item(itype_flippers));
24322 b=1;
24323
24324 if(cy&8)
24325 {
24326 b<<=1;
24327 }
24328 }
24329
24330 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24331
24332 if((c.walk&b) && !dried && !swim)
24333 {
24334 return true;
24335 }
24336
24337 cx+=8;
24338
24339 if(cx&7)
24340 {
24341 if(!(cx&8))
24342 {
24343 b<<=2;
24344 }
24345 else
24346 {
24347 c = combobuf[TheMaps[ns].data[++cmb]];
24348 dried = iswater_type(c.type) && DRIEDLAKE;
24349 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24350 b=1;
24351
24352 if(cy&8)
24353 {
24354 b<<=1;
24355 }
24356 }
24357
24358 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24359
24360 if((c.walk&b) && !dried && !swim)
24361 return true;
24362 }
24363
24364 #endif
24365 */
24366 }
24367
24368 return false;
24369 }
24370
24371 3628648 void HeroClass::checkscroll()
24372 {
24373 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
24374
2/4
✓ Branch 0 taken 3628648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3628648 times.
✗ Branch 3 not taken.
3628648 if(action == casting||action==sideswimcasting)
24375 return;
24376
24377
2/2
✓ Branch 0 taken 3615242 times.
✓ Branch 1 taken 13406 times.
3628648 if(toogam)
24378 {
24379
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(x<0 && (currscr&15)==0) x=0;
24380
24381
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13386 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
13406 if(y<0 && currscr<16) y=0;
24382
24383
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13391 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
13406 if(x>240 && (currscr&15)==15) x=240;
24384
24385
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(y>160 && currscr>=112) y=160;
24386 13406 }
24387
24388
2/2
✓ Branch 0 taken 3626712 times.
✓ Branch 1 taken 1936 times.
3628648 if(y<0)
24389 {
24390 1936 bool doit=true;
24391 1936 y=0;
24392
24393
3/6
✓ Branch 0 taken 1936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1936 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1936 times.
1936 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24394 doit = false;
24395
24396
1/2
✓ Branch 0 taken 1936 times.
✗ Branch 1 not taken.
1936 if(nextcombo_wf(up))
24397 doit=false;
24398
24399
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1936 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1936 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
24400 {
24401 if(nextcombo_solid(up))
24402 doit=false;
24403 }
24404
24405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1936 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1936 if(doit || action==inwind)
24406 {
24407
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 1683 times.
1936 if(currscr>=128)
24408 {
24409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 if(specialcave >= GUYCAVE)
24410 exitcave();
24411 253 else stepout();
24412 253 }
24413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
1683 else if(action==inwind)
24414 {
24415 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24416 {
24417 action=none; FFCore.setHeroAction(none);
24418 restart_level();
24419 }
24420 else
24421 {
24422 dowarp(2,up);
24423 }
24424 }
24425
3/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1683 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24426 {
24427 38 sdir=up;
24428 38 dowarp(1,(tmpscr->sidewarpindex)&3);
24429 38 }
24430
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1585 times.
1645 else if(!edge_of_dmap(up))
24431 {
24432 1585 scrolling_map = currmap;
24433 1585 scrollscr(up);
24434
24435
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(tmpscr->flags4&fAUTOSAVE)
24436 {
24437 save_game(true,0);
24438 }
24439
24440
2/2
✓ Branch 0 taken 1581 times.
✓ Branch 1 taken 4 times.
1585 if(tmpscr->flags6&fCONTINUEHERE)
24441 {
24442 4 lastentrance_dmap = currdmap;
24443 4 lastentrance = homescr;
24444 4 }
24445 1585 }
24446 1936 }
24447 1936 }
24448
24449
2/2
✓ Branch 0 taken 3627412 times.
✓ Branch 1 taken 1236 times.
3628648 if(y>160)
24450 {
24451 1236 bool doit=true;
24452 1236 y=160;
24453
24454
4/6
✓ Branch 0 taken 1235 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1235 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1236 times.
1236 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24455 doit = false;
24456
24457
1/2
✓ Branch 0 taken 1236 times.
✗ Branch 1 not taken.
1236 if(nextcombo_wf(down))
24458 doit=false;
24459
24460
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1236 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1236 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
24461 {
24462 if(nextcombo_solid(down))
24463 doit=false;
24464 }
24465
24466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1236 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1236 if(doit || action==inwind)
24467 {
24468
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 1074 times.
1236 if(currscr>=128)
24469 {
24470
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(specialcave >= GUYCAVE)
24471 162 exitcave();
24472 else stepout();
24473 162 }
24474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1074 times.
1074 else if(action==inwind)
24475 {
24476 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24477 {
24478 action=none; FFCore.setHeroAction(none);
24479 restart_level();
24480 }
24481 else
24482 {
24483 dowarp(2,down);
24484 }
24485 }
24486
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1010 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1074 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24487 {
24488 64 sdir=down;
24489 64 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24490 64 }
24491
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1005 times.
1010 else if(!edge_of_dmap(down))
24492 {
24493 1005 scrolling_map = currmap;
24494 1005 scrollscr(down);
24495
24496
1/2
✓ Branch 0 taken 1005 times.
✗ Branch 1 not taken.
1005 if(tmpscr->flags4&fAUTOSAVE)
24497 {
24498 save_game(true,0);
24499 }
24500
24501
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 2 times.
1005 if(tmpscr->flags6&fCONTINUEHERE)
24502 {
24503 2 lastentrance_dmap = currdmap;
24504 2 lastentrance = homescr;
24505 2 }
24506 1005 }
24507 1236 }
24508 1236 }
24509
24510
2/2
✓ Branch 0 taken 3627246 times.
✓ Branch 1 taken 1402 times.
3628648 if(x<0)
24511 {
24512 1402 bool doit=true;
24513 1402 x=0;
24514
24515
3/6
✓ Branch 0 taken 1402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1402 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1402 times.
1402 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24516 doit = false;
24517
24518
1/2
✓ Branch 0 taken 1402 times.
✗ Branch 1 not taken.
1402 if(nextcombo_wf(left))
24519 doit=false;
24520
24521
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1402 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
24522 {
24523 if(nextcombo_solid(left))
24524 doit=false;
24525 }
24526
24527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1402 if(doit || action==inwind)
24528 {
24529
1/2
✓ Branch 0 taken 1402 times.
✗ Branch 1 not taken.
1402 if(currscr>=128)
24530 {
24531 if(specialcave >= GUYCAVE)
24532 exitcave();
24533 else stepout();
24534 }
24535
24536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
1402 if(action==inwind)
24537 {
24538 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24539 {
24540 action=none; FFCore.setHeroAction(none);
24541 restart_level();
24542 }
24543 else
24544 {
24545 dowarp(2,left);
24546 }
24547 }
24548
3/6
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1356 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1402 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24549 {
24550 46 sdir=left;
24551 46 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24552 46 }
24553
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 1267 times.
1356 else if(!edge_of_dmap(left))
24554 {
24555 1267 scrolling_map = currmap;
24556 1267 scrollscr(left);
24557
24558
1/2
✓ Branch 0 taken 1267 times.
✗ Branch 1 not taken.
1267 if(tmpscr->flags4&fAUTOSAVE)
24559 {
24560 save_game(true,0);
24561 }
24562
24563
2/2
✓ Branch 0 taken 1259 times.
✓ Branch 1 taken 8 times.
1267 if(tmpscr->flags6&fCONTINUEHERE)
24564 {
24565 8 lastentrance_dmap = currdmap;
24566 8 lastentrance = homescr;
24567 8 }
24568 1267 }
24569 1402 }
24570 1402 }
24571
24572
2/2
✓ Branch 0 taken 3627058 times.
✓ Branch 1 taken 1590 times.
3628648 if(x>240)
24573 {
24574 1590 bool doit=true;
24575 1590 x=240;
24576
24577
3/6
✓ Branch 0 taken 1590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1590 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1590 times.
1590 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24578 doit = false;
24579
24580
1/2
✓ Branch 0 taken 1590 times.
✗ Branch 1 not taken.
1590 if(nextcombo_wf(right))
24581 doit=false;
24582
24583
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1590 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1590 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
24584 {
24585 if(nextcombo_solid(right))
24586 doit=false;
24587 }
24588
24589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1590 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1590 if(doit || action==inwind)
24590 {
24591
1/2
✓ Branch 0 taken 1590 times.
✗ Branch 1 not taken.
1590 if(currscr>=128)
24592 {
24593 if(specialcave >= GUYCAVE)
24594 exitcave();
24595 else stepout();
24596 }
24597
24598
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1569 times.
1590 if(action==inwind)
24599 {
24600
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 20 times.
21 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24601 {
24602 1 action=none; FFCore.setHeroAction(none);
24603 1 restart_level();
24604 1 }
24605 else
24606 {
24607 20 dowarp(2,right);
24608 }
24609 21 }
24610
3/6
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 1492 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1569 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24611 {
24612 77 sdir=right;
24613 77 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
24614 77 }
24615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1492 times.
1492 else if(!edge_of_dmap(right))
24616 {
24617 1492 scrolling_map = currmap;
24618 1492 scrollscr(right);
24619
24620
1/2
✓ Branch 0 taken 1492 times.
✗ Branch 1 not taken.
1492 if(tmpscr->flags4&fAUTOSAVE)
24621 {
24622 save_game(true,0);
24623 }
24624
24625
2/2
✓ Branch 0 taken 1482 times.
✓ Branch 1 taken 10 times.
1492 if(tmpscr->flags6&fCONTINUEHERE)
24626 {
24627 10 lastentrance_dmap = currdmap;
24628 10 lastentrance = homescr;
24629 10 }
24630 1492 }
24631 1590 }
24632 1590 }
24633 3628648 }
24634
24635 // assumes current direction is in lastdir[3]
24636 // compares directions with scr->path and scr->exitdir
24637 16154 bool HeroClass::checkmaze(mapscr *scr, bool sound)
24638 {
24639
2/2
✓ Branch 0 taken 15994 times.
✓ Branch 1 taken 160 times.
16154 if(!(scr->flags&fMAZE))
24640 15994 return true;
24641
24642
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 136 times.
160 if(lastdir[3]==scr->exitdir)
24643 24 return true;
24644
24645
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 20 times.
225 for(int32_t i=0; i<4; i++)
24646
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 116 times.
205 if(lastdir[i]!=scr->path[i])
24647 116 return false;
24648
24649
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
20 if(sound)
24650 10 sfx(scr->secretsfx);
24651
24652 20 return true;
24653 16154 }
24654
24655 10805 bool HeroClass::edge_of_dmap(int32_t side)
24656 {
24657
2/2
✓ Branch 0 taken 10736 times.
✓ Branch 1 taken 69 times.
10805 if(checkmaze(tmpscr,false)==false)
24658 69 return false;
24659
24660 // needs fixin'
24661 // should check dmap style
24662
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3179 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 2590 times.
✓ Branch 4 taken 2968 times.
10736 switch(side)
24663 {
24664 case up:
24665 3179 return currscr<16;
24666
24667 case down:
24668 1999 return currscr>=112;
24669
24670 case left:
24671
2/2
✓ Branch 0 taken 2501 times.
✓ Branch 1 taken 89 times.
2590 if((currscr&15)==0)
24672 89 return true;
24673
24674
2/2
✓ Branch 0 taken 1486 times.
✓ Branch 1 taken 1015 times.
2501 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24675 // if(dlevel)
24676 1486 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
24677
24678 1015 break;
24679
24680 case right:
24681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2968 times.
2968 if((currscr&15)==15)
24682 return true;
24683
24684
2/2
✓ Branch 0 taken 1807 times.
✓ Branch 1 taken 1161 times.
2968 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24685 // if(dlevel)
24686 1807 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
24687
24688 1161 break;
24689 }
24690
24691 2176 return false;
24692 10805 }
24693
24694 87 bool HeroClass::lookaheadraftflag(int32_t d2)
24695 {
24696 // Helper for scrollscr that gets next combo on next screen.
24697 // Can use destscr for scrolling warps,
24698 // but assumes currmap is correct.
24699
24700 87 int32_t cx = x;
24701 87 int32_t cy = y + 8;
24702
24703 87 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24704 87 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24705 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24706 //Applying this here, too. -Z
24707
24708
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 25 times.
87 switch(d2)
24709 {
24710 case up:
24711 24 cy=160;
24712 24 break;
24713
24714 case down:
24715 16 cy=0;
24716 16 break;
24717
24718 case left:
24719 22 cx=240;
24720 22 break;
24721
24722 case right:
24723 25 cx=0;
24724 25 break;
24725 }
24726
24727 87 int32_t combo = (cy&0xF0)+(cx>>4);
24728
24729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(combo>175)
24730 return 0;
24731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
24732
24733 87 }
24734 5493 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
24735 {
24736 // Can use destscr for scrolling warps,
24737 // but assumes currmap is correct.
24738
24739 5493 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
24740 5493 int32_t cy = vbound(y + 8,0,160);
24741 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24742 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24743 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24744
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1601 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 1295 times.
✓ Branch 4 taken 1557 times.
5493 switch(d2)
24745 {
24746 case up:
24747 1601 cy=160;
24748 1601 break;
24749
24750 case down:
24751 1040 cy=0;
24752 1040 break;
24753
24754 case left:
24755 1295 cx=240;
24756 1295 break;
24757
24758 case right:
24759 1557 cx=0;
24760 1557 break;
24761 }
24762
24763 5493 int32_t combo = (cy&0xF0)+(cx>>4);
24764
24765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
5493 if(combo>175)
24766 return 0;
24767
24768 5493 return tmpscr[0].data[combo]; // entire combo code
24769 5493 }
24770
24771 5493 int32_t HeroClass::lookaheadflag(int32_t d2)
24772 {
24773 // Helper for scrollscr that gets next combo on next screen.
24774 // Can use destscr for scrolling warps,
24775 // but assumes currmap is correct.
24776
24777 5493 int32_t cx = vbound(x,0,240);
24778 5493 int32_t cy = vbound(y + 8,0,160);
24779
24780 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24781 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24782 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24783 //Applying this here, too. -Z
24784
24785
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1601 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 1295 times.
✓ Branch 4 taken 1557 times.
5493 switch(d2)
24786 {
24787 case up:
24788 1601 cy=160;
24789 1601 break;
24790
24791 case down:
24792 1040 cy=0;
24793 1040 break;
24794
24795 case left:
24796 1295 cx=240;
24797 1295 break;
24798
24799 case right:
24800 1557 cx=0;
24801 1557 break;
24802 }
24803
24804 5493 int32_t combo = (cy&0xF0)+(cx>>4);
24805
24806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
5493 if(combo>175)
24807 return 0;
24808
24809
2/2
✓ Branch 0 taken 5338 times.
✓ Branch 1 taken 155 times.
5493 if(!tmpscr[0].sflag[combo])
24810 {
24811 5338 return combobuf[tmpscr[0].data[combo]].flag; // flag
24812 }
24813
24814 155 return tmpscr[0].sflag[combo]; // flag
24815 5493 }
24816
24817 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
24818 793705 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
24819 {
24820 // For rafting (and possibly other esoteric things)
24821 // Hero's action should remain unchanged while scrolling,
24822 // but for the sake of scripts, here's an eye-watering kludge.
24823 793705 actiontype lastaction = action;
24824 793705 action=scrolling; FFCore.setHeroAction(scrolling);
24825
2/2
✓ Branch 0 taken 396745 times.
✓ Branch 1 taken 396960 times.
793705 if(waitdraw)
24826 {
24827 396745 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
24828 396745 }
24829 else
24830 {
24831 396960 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
24832 }
24833 793705 zfix storex = x, storey = y;
24834
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 207061 times.
✓ Branch 2 taken 125048 times.
✓ Branch 3 taken 207756 times.
✓ Branch 4 taken 253840 times.
793705 switch(scrolldir)
24835 {
24836 case up:
24837
2/2
✓ Branch 0 taken 175801 times.
✓ Branch 1 taken 31260 times.
207061 if(y < 160) y = 176;
24838
4/4
✓ Branch 0 taken 26721 times.
✓ Branch 1 taken 4539 times.
✓ Branch 2 taken 8918 times.
✓ Branch 3 taken 17803 times.
31260 else if(cx > 0 && !end_frames) y = sy + 156;
24839 13457 else y = 160;
24840
24841 207061 break;
24842
24843 case down:
24844
2/2
✓ Branch 0 taken 105920 times.
✓ Branch 1 taken 19128 times.
125048 if(y > 0) y = -16;
24845
4/4
✓ Branch 0 taken 16125 times.
✓ Branch 1 taken 3003 times.
✓ Branch 2 taken 6195 times.
✓ Branch 3 taken 9930 times.
19128 else if(cx > 0 && !end_frames) y = sy - 172;
24846 9198 else y = 0;
24847
24848 125048 break;
24849
24850 case left:
24851
2/2
✓ Branch 0 taken 191217 times.
✓ Branch 1 taken 16539 times.
207756 if(x < 240) x = 256;
24852
2/2
✓ Branch 0 taken 13897 times.
✓ Branch 1 taken 2642 times.
16539 else if(cx > 0) x = sx + 236;
24853 2642 else x = 240;
24854
24855 207756 break;
24856
24857 case right:
24858
2/2
✓ Branch 0 taken 233703 times.
✓ Branch 1 taken 20137 times.
253840 if(x > 0) x = -16;
24859
2/2
✓ Branch 0 taken 16961 times.
✓ Branch 1 taken 3176 times.
20137 else if(cx > 0) x = sx - 252;
24860 3176 else x = 0;
24861
24862 253840 break;
24863 }
24864
2/2
✓ Branch 0 taken 396745 times.
✓ Branch 1 taken 396960 times.
793705 if(waitdraw)
24865 {
24866
3/4
✓ Branch 0 taken 396745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 301810 times.
✓ Branch 3 taken 94935 times.
396745 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
24867 {
24868 94935 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24869 94935 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
24870 94935 }
24871 396745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
24872
4/6
✓ Branch 0 taken 396745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 393338 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3407 times.
396745 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24873 {
24874 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24875 3407 player_waitdraw = false;
24876 3407 }
24877 396745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
24878
4/6
✓ Branch 0 taken 396745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 396711 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
396745 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24879 {
24880 34 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24881 34 dmap_waitdraw = false;
24882 34 }
24883 396745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
24884
2/6
✓ Branch 0 taken 396745 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 396745 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
396745 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24885 {
24886 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24887 passive_subscreen_waitdraw = false;
24888 }
24889 396745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
24890
4/10
✓ Branch 0 taken 396745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 396728 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
396745 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24891 {
24892 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24893 tmpscr->screen_waitdraw = 0;
24894 }
24895 396745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
24896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396745 times.
396745 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
24897 {
24898 396745 FFCore.itemScriptEngineOnWaitdraw();
24899 396745 }
24900 396745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
24901 396745 }
24902 else
24903 {
24904
4/8
✓ Branch 0 taken 396960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 396942 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
396960 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24905 {
24906 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24907 }
24908 396960 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
24909
3/4
✓ Branch 0 taken 396960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249368 times.
✓ Branch 3 taken 147592 times.
396960 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
24910 {
24911 147592 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24912 147592 }
24913 396960 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
24914
5/6
✓ Branch 0 taken 396960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 389545 times.
✓ Branch 3 taken 7415 times.
✓ Branch 4 taken 386138 times.
✓ Branch 5 taken 3407 times.
396960 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
24915 {
24916 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24917 3407 }
24918 396960 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
24919
4/6
✓ Branch 0 taken 396960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 386138 times.
✓ Branch 5 taken 10822 times.
396960 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24920 {
24921 10822 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24922 10822 }
24923 396960 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
24924
4/6
✓ Branch 0 taken 396960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 386138 times.
✓ Branch 5 taken 10822 times.
396960 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24925 {
24926 10822 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24927 10822 }
24928 396960 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
24929 396960 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
24930
3/4
✓ Branch 0 taken 396960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4640 times.
✓ Branch 3 taken 392320 times.
396960 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
24931 392320 FFCore.itemScriptEngine();
24932 396960 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
24933
3/4
✓ Branch 0 taken 396960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392320 times.
✓ Branch 3 taken 4640 times.
396960 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
24934 4640 FFCore.itemScriptEngine();
24935 }
24936
24937 793705 x = storex, y = storey;
24938
24939 793705 action=lastaction; FFCore.setHeroAction(lastaction);
24940 793705 }
24941
24942 //Has solving the maze enabled a side warp?
24943 //Only used just before scrolling screens
24944 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
24945 // return true to abort the topmost scrollscr() call. -L
24946 5493 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
24947 {
24948
2/2
✓ Branch 0 taken 16479 times.
✓ Branch 1 taken 5493 times.
21972 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
24949
24950
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 5424 times.
5493 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
24951
24952
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5493 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
24953 {
24954 switch(scrolldir)
24955 {
24956 case up:
24957 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
24958 {
24959 lastdir[3] = 0xFF;
24960 sdir=up;
24961 dowarp(1,(tmpscr->sidewarpindex)&3);
24962 return true;
24963 }
24964
24965 break;
24966
24967 case down:
24968 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
24969 {
24970 lastdir[3] = 0xFF;
24971 sdir=down;
24972 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24973 return true;
24974 }
24975
24976 break;
24977
24978 case left:
24979 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
24980 {
24981 lastdir[3] = 0xFF;
24982 sdir=left;
24983 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24984 return true;
24985 }
24986
24987 break;
24988
24989 case right:
24990 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
24991 {
24992 lastdir[3] = 0xFF;
24993 sdir=right;
24994 dowarp(1,(tmpscr->sidewarpindex)&3);
24995 return true;
24996 }
24997
24998 break;
24999 }
25000 }
25001
25002 5493 return false;
25003 5493 }
25004
25005 5493 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
25006 {
25007 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
25008
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 4939 times.
5493 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
25009 554 return 16;
25010
25011
2/2
✓ Branch 0 taken 3910 times.
✓ Branch 1 taken 1029 times.
4939 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
25012 {
25013
2/2
✓ Branch 0 taken 1955 times.
✓ Branch 1 taken 1955 times.
3910 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25014 }
25015 else
25016 {
25017
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
25018 {
25019 482 return 8;
25020 }
25021 else
25022 {
25023
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 332 times.
547 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25024 }
25025 }
25026 5493 }
25027
25028 5493 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
25029 {
25030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
5493 if(get_bit(quest_rules, qr_NOSCROLL))
25031 return 0;
25032
25033
4/4
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 3910 times.
✓ Branch 3 taken 1029 times.
5493 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
25034 4939 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
25035 {
25036 4464 return 1;
25037 }
25038 else
25039 {
25040
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
25041 {
25042
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 234 times.
482 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
25043 }
25044 else
25045 {
25046 547 return 1;
25047 }
25048 }
25049 5493 }
25050
25051 5545 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
25052 {
25053 5545 int32_t itemid = current_item_id(itype_lantern);
25054
1/2
✓ Branch 0 taken 5545 times.
✗ Branch 1 not taken.
5545 if(itemid < 0) return; //no lantern light circle
25055 5545 int32_t hx1 = x.getInt() - x1 + 8;
25056 5545 int32_t hy1 = y.getInt() - y1 + 8;
25057 5545 int32_t hx2 = x.getInt() - x2 + 8;
25058 5545 int32_t hy2 = y.getInt() - y2 + 8;
25059
25060 5545 itemdata& lamp = itemsbuf[itemid];
25061
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5545 times.
✗ Branch 2 not taken.
5545 switch(lamp.misc1) //Shape
25062 {
25063 case 0: //Circle
25064 5545 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
25065 5545 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
25066 5545 break;
25067 case 1: //Lamp Cone
25068 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
25069 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
25070 break;
25071 }
25072 5545 }
25073
25074 5493 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
25075 {
25076
2/4
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5493 times.
5493 if(action==freeze||action==sideswimfreeze)
25077 {
25078 return;
25079 }
25080
25081 5493 bool overlay = false;
25082
25083
2/4
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5493 times.
5493 if(scrolldir >= 0 && scrolldir <= 3)
25084 {
25085 5493 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
25086 5493 }
25087
25088
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 5349 times.
5493 if(destdmap == -1)
25089 {
25090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5349 times.
5349 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
25091
1/2
✓ Branch 0 taken 5349 times.
✗ Branch 1 not taken.
5349 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
25092 return;
25093 5349 }
25094 else
25095 {
25096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
25097
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
25098 return;
25099 }
25100
25101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
5493 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
25102 return;
25103
25104 5493 kill_enemy_sfx();
25105 5493 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25106 5493 screenscrolling = true;
25107 5493 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
25108
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1601 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 1295 times.
✓ Branch 4 taken 1557 times.
5493 switch(scrolldir)
25109 {
25110 case up:
25111 1601 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25112 1601 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
25113 1601 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25114 1601 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25115 1601 break;
25116 case down:
25117 1040 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25118 1040 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
25119 1040 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25120 1040 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25121 1040 break;
25122 case left:
25123 1295 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
25124 1295 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25125 1295 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25126 1295 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25127 1295 break;
25128 case right:
25129 1557 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
25130 1557 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25131 1557 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25132 1557 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25133 1557 break;
25134 }
25135 5493 FFCore.init_combo_doscript();
25136 5493 tmpscr[1] = tmpscr[0];
25137
25138 5493 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
25139
25140
2/2
✓ Branch 0 taken 32958 times.
✓ Branch 1 taken 5493 times.
38451 for(int32_t i = 0; i < 6; i++)
25141 {
25142 32958 tmpscr3[i] = tmpscr2[i];
25143 32958 }
25144
25145 5493 conveyclk = 2;
25146
25147 5493 mapscr *newscr = &tmpscr[0];
25148 5493 mapscr *oldscr = &tmpscr[1];
25149
25150 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
25151 5493 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
25152 5493 int32_t cx = 0;
25153 5493 int32_t step = get_scroll_step(scrolldir);
25154 5493 int32_t delay = get_scroll_delay(scrolldir);
25155 5493 bool end_frames = false;
25156
25157 5493 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
25158
2/2
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 554 times.
5493 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
25159 554 scx = 32; //for sideview very fast screolling.
25160
25161
25162 5493 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
25163 5493 actiontype lastaction = action;
25164 5493 ALLOFF(false, false);
25165 // for now, restore Hero's previous action
25166
2/2
✓ Branch 0 taken 5278 times.
✓ Branch 1 taken 215 times.
5493 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
25167 5493 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
25168 5493 action=lastaction; FFCore.setHeroAction(lastaction);
25169
25170 5493 lstep = (lstep + 6) % 12;
25171 5493 cx = scx;
25172 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
25173
3/4
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3480 times.
✓ Branch 3 taken 2013 times.
5493 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
25174 {
25175 2013 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25176 2013 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
25177 2013 }
25178 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
25179
4/6
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 5299 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
5493 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25180 {
25181 194 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25182 194 player_waitdraw = false;
25183 194 }
25184 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
25185
4/6
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5491 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
5493 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25186 {
25187 2 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25188 2 dmap_waitdraw = false;
25189 2 }
25190 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
25191
2/6
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5493 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5493 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25192 {
25193 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25194 passive_subscreen_waitdraw = false;
25195 }
25196 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
25197
2/8
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5493 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5493 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25198 {
25199 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25200 tmpscr->screen_waitdraw = 0;
25201 }
25202 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
25203
25204 5493 word c = tmpscr->numFFC();
25205
2/2
✓ Branch 0 taken 170099 times.
✓ Branch 1 taken 5493 times.
175592 for ( word q = 0; q < c; ++q )
25206 {
25207 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
25208
1/2
✓ Branch 0 taken 170099 times.
✗ Branch 1 not taken.
170099 if ( tmpscr->ffcswaitdraw&(1<<q) )
25209 {
25210 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
25211 if(tmpscr->ffcs[q].script != 0)
25212 {
25213 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
25214 tmpscr->ffcswaitdraw &= ~(1<<q);
25215 }
25216 }
25217 170099 }
25218 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
25219 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
25220 //Waitdraw for item scripts.
25221 5493 FFCore.itemScriptEngineOnWaitdraw();
25222 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
25223 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
25224
25225 //Sprite scripts on Waitdraw
25226 5493 FFCore.eweaponScriptEngineOnWaitdraw();
25227 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
25228 5493 FFCore.itemSpriteScriptEngineOnWaitdraw();
25229 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
25230
25231 //This is no longer a do-while, as the first iteration is now slightly different. -Em
25232 5493 draw_screen(tmpscr,true,true);
25233
25234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
5493 if(cx == scx)
25235 5493 rehydratelake(false);
25236
25237 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25238 5493 advanceframe(true);
25239
25240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
5493 if(Quit)
25241 {
25242 screenscrolling = false;
25243 return;
25244 }
25245
25246 5493 ++cx;
25247
2/2
✓ Branch 0 taken 104269 times.
✓ Branch 1 taken 5493 times.
109762 while(cx < 32)
25248 {
25249
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 104255 times.
104269 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
25250 {
25251 14 script_drawing_commands.Clear();
25252 14 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25253 14 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
25254 14 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25255 14 }
25256 104255 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25257 104269 draw_screen(tmpscr,true,true);
25258
25259
1/2
✓ Branch 0 taken 104269 times.
✗ Branch 1 not taken.
104269 if(cx == scx)
25260 rehydratelake(false);
25261
25262 104269 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25263 104269 advanceframe(true);
25264
25265
1/2
✓ Branch 0 taken 104269 times.
✗ Branch 1 not taken.
104269 if(Quit)
25266 {
25267 screenscrolling = false;
25268 return;
25269 }
25270
25271 104269 ++cx;
25272 }
25273 5493 script_drawing_commands.Clear();
25274 5493 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25275
25276
25277 //clear Hero's last hits
25278 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
25279
25280
3/4
✓ Branch 0 taken 2579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 496 times.
✓ Branch 3 taken 2418 times.
5493 switch(DMaps[currdmap].type&dmfTYPE)
25281 {
25282 case dmDNGN:
25283
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
25284 {
25285 markBmap(scrolldir);
25286 }
25287 2418 break;
25288 case dmOVERW: case dmBSOVERW:
25289
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2517 times.
2579 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
25290 2517 break;
25291 [[fallthrough]];
25292 case dmCAVE:
25293 558 markBmap(scrolldir);
25294 558 break;
25295 }
25296
25297
1/2
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
5493 if(fixed_door)
25298 {
25299 unsetmapflag(mSECRET);
25300 fixed_door = false;
25301 }
25302 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
25303 5493 scrolling_scr = currscr;
25304
25305
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1601 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 1295 times.
✓ Branch 4 taken 1557 times.
5493 switch(scrolldir)
25306 {
25307 case up:
25308 {
25309
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1585 times.
1601 if(destscr != -1)
25310 16 currscr = destscr;
25311
3/4
✓ Branch 0 taken 1561 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1561 times.
1585 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25312 1561 currscr -= 16;
25313
25314 1601 loadscr(0,destdmap,currscr,scrolldir,overlay);
25315 1601 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
25316 1601 putscr(scrollbuf,0,0,newscr);
25317 1601 putscrdoors(scrollbuf,0,0,newscr);
25318 1601 sy=176;
25319
25320
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 327 times.
1601 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25321 327 sy+=3;
25322
25323 1601 cx=176/step;
25324 1601 FFCore.init_combo_doscript();
25325 }
25326 1601 break;
25327
25328 case down:
25329 {
25330
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1005 times.
1040 if(destscr != -1)
25331 35 currscr = destscr;
25332
3/4
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 999 times.
1005 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25333 999 currscr += 16;
25334
25335 1040 loadscr(0,destdmap,currscr,scrolldir,overlay);
25336 1040 putscr(scrollbuf,0,176,newscr);
25337 1040 putscrdoors(scrollbuf,0,176,newscr);
25338 1040 sy = 0;
25339
25340
2/2
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 155 times.
1040 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25341 155 sy+=3;
25342
25343 1040 cx = 176 / step;
25344 1040 FFCore.init_combo_doscript();
25345 }
25346 1040 break;
25347
25348 case left:
25349 {
25350
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1267 times.
1295 if(destscr!=-1)
25351 28 currscr = destscr;
25352
3/4
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1256 times.
1267 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25353 1256 --currscr;
25354
25355 1295 loadscr(0,destdmap,currscr,scrolldir,overlay);
25356 1295 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
25357 1295 putscr(scrollbuf,0,0,newscr);
25358 1295 putscrdoors(scrollbuf,0,0,newscr);
25359 1295 sx = 256;
25360 1295 cx = 256 / step;
25361 1295 FFCore.init_combo_doscript();
25362 }
25363 1295 break;
25364
25365 case right:
25366 {
25367
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 1492 times.
1557 if(destscr != -1)
25368 65 currscr = destscr;
25369
3/4
✓ Branch 0 taken 1486 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1486 times.
1492 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25370 1486 ++currscr;
25371
25372 1557 loadscr(0,destdmap,currscr,scrolldir,overlay);
25373 1557 putscr(scrollbuf,256,0,newscr);
25374 1557 putscrdoors(scrollbuf,256,0,tmpscr);
25375 1557 sx = 0;
25376 1557 cx = 256 / step;
25377 1557 FFCore.init_combo_doscript();
25378 }
25379 1557 break;
25380 }
25381
25382 // change Hero's state if entering water
25383 5493 int32_t ahead = lookahead(scrolldir);
25384 5493 int32_t aheadflag = lookaheadflag(scrolldir);
25385 5493 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
25386 5493 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
25387 5493 int32_t wateraheadx1 = vbound(x+4,0,240);
25388 5493 int32_t wateraheadx2 = vbound(x+11,0,240);;
25389 5493 int32_t wateraheady1 = vbound(y+9,0,160);
25390 5493 int32_t wateraheady2 = vbound(y+15,0,160);
25391 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25392 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25393 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
25394
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1601 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 1295 times.
✓ Branch 4 taken 1557 times.
5493 switch(scrolldir)
25395 {
25396 case up:
25397 1601 lookaheady=160;
25398 1601 wateraheady1=160;
25399 1601 wateraheady2=160;
25400 1601 break;
25401
25402 case down:
25403 1040 lookaheady=0;
25404 1040 wateraheady1=0;
25405 1040 wateraheady2=0;
25406 1040 break;
25407
25408 case left:
25409 1295 lookaheadx=240;
25410 1295 wateraheadx1=240;
25411 1295 wateraheadx2=240;
25412 1295 break;
25413
25414 case right:
25415 1557 lookaheadx=0;
25416 1557 wateraheadx1=0;
25417 1557 wateraheadx2=0;
25418 1557 break;
25419 }
25420
25421 5493 bool nowinwater = false;
25422
25423
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5473 times.
5493 if(lastaction != inwind)
25424 {
25425
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 5386 times.
5473 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
25426 {
25427
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 80 times.
87 if (lookaheadraftflag(scrolldir))
25428 {
25429 80 action=rafting; FFCore.setHeroAction(rafting);
25430 80 raftclk=0;
25431 80 }
25432 87 }
25433
5/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 5300 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 65 times.
5386 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
25434 {
25435
9/16
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
65 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
25436 {
25437 62 SetSwim();
25438 62 hopclk = 0xFF;
25439 62 nowinwater = true;
25440 62 }
25441 else
25442 {
25443 3 action=hopping; FFCore.setHeroAction(hopping);
25444 3 hopclk = 2;
25445 3 nowinwater = true;
25446 }
25447 65 }
25448
3/4
✓ Branch 0 taken 5308 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5321 times.
5321 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
25449 {
25450 action = lastaction; FFCore.setHeroAction(lastaction);
25451 }
25452 else
25453 {
25454 5321 action=none; FFCore.setHeroAction(none);
25455 }
25456 5473 }
25457
25458 // The naturaldark state can be read/set by an FFC script before
25459 // fade() or lighting() is called.
25460 5493 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
25461
25462
2/2
✓ Branch 0 taken 5387 times.
✓ Branch 1 taken 106 times.
5493 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
25463
25464
2/2
✓ Branch 0 taken 5360 times.
✓ Branch 1 taken 133 times.
5493 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
25465 //Preloaded ffc scripts
25466 5493 homescr=currscr;
25467 5493 auto olddmap = currdmap;
25468
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 5349 times.
5493 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
25469
25470 5493 currdmap = newdmap;
25471 5493 ffscript_engine(true);
25472 5493 currdmap = olddmap;
25473
25474 // There are two occasions when scrolling must be darkened:
25475 // 1) When scrolling into a dark room.
25476 // 2) When scrolling between DMaps of different colours.
25477
4/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 5349 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 92 times.
5493 if(destdmap != -1 && DMaps[destdmap].color != currcset)
25478 {
25479
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
25480 92 darkroom = true;
25481 92 }
25482
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 5258 times.
5401 else if(!darkroom)
25483 5258 lighting(false, false); // NES behaviour: fade to dark before scrolling
25484
25485
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 5406 times.
5493 if(action != rafting) // Is this supposed to be here?!
25486
25487 5406 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
25488
25489 5493 cx *= delay; //so we can have drawing re-done every frame,
25490 //previously it was for(0 to delay) advanceframes at end of loop
25491 5493 int32_t no_move = 0;
25492
25493 5493 currdmap = newdmap;
25494
4/4
✓ Branch 0 taken 5493 times.
✓ Branch 1 taken 396731 times.
✓ Branch 2 taken 396731 times.
✓ Branch 3 taken 5493 times.
402224 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
25495 {
25496
3/4
✓ Branch 0 taken 396731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275282 times.
✓ Branch 3 taken 121449 times.
396731 if (replay_is_active() && replay_get_version() < 3)
25497 {
25498 121449 replay_poll();
25499 121449 }
25500
1/2
✓ Branch 0 taken 396731 times.
✗ Branch 1 not taken.
396731 if(Quit)
25501 {
25502 screenscrolling = false;
25503 return;
25504 }
25505
25506
25507 396731 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
25508
25509
2/2
✓ Branch 0 taken 358354 times.
✓ Branch 1 taken 38377 times.
396731 if(no_move > 0)
25510 38377 no_move--;
25511
25512 //Don't want to move things on the first or last iteration, or between delays
25513
6/6
✓ Branch 0 taken 391238 times.
✓ Branch 1 taken 5493 times.
✓ Branch 2 taken 383586 times.
✓ Branch 3 taken 7652 times.
✓ Branch 4 taken 23129 times.
✓ Branch 5 taken 360457 times.
396731 if(i == 0 || cx == 0 || cx % delay != 0)
25514 36274 no_move++;
25515
25516
4/4
✓ Branch 0 taken 293233 times.
✓ Branch 1 taken 103498 times.
✓ Branch 2 taken 62504 times.
✓ Branch 3 taken 230729 times.
396731 if(scrolldir == up || scrolldir == down)
25517 {
25518
2/2
✓ Branch 0 taken 130825 times.
✓ Branch 1 taken 35177 times.
166002 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
25519 {
25520 //Add a few extra frames if on the second loop and cool scrolling is not set
25521
2/2
✓ Branch 0 taken 34695 times.
✓ Branch 1 taken 482 times.
35177 if(i == 1)
25522 {
25523 482 cx += (scrolldir == down) ? 3 : 2;
25524 482 no_move += (scrolldir == down) ? 3 : 2;
25525 482 }
25526 35177 }
25527 else
25528 {
25529 //4 frames after we've finished scrolling of being still
25530
4/4
✓ Branch 0 taken 4318 times.
✓ Branch 1 taken 126507 times.
✓ Branch 2 taken 2159 times.
✓ Branch 3 taken 2159 times.
130825 if(cx == 0 && !end_frames)
25531 {
25532 2159 cx += 4;
25533 2159 no_move += 4;
25534 2159 end_frames = true;
25535 2159 }
25536 }
25537 166002 }
25538
25539 //Move Hero and the scroll position
25540
2/2
✓ Branch 0 taken 43870 times.
✓ Branch 1 taken 352861 times.
396731 if(!no_move)
25541 {
25542
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 78420 times.
✓ Branch 2 taken 49416 times.
✓ Branch 3 taken 101258 times.
✓ Branch 4 taken 123767 times.
352861 switch(scrolldir)
25543 {
25544 case up:
25545 78420 sy -= step;
25546 78420 y += step;
25547 78420 break;
25548
25549 case down:
25550 49416 sy += step;
25551 49416 y -= step;
25552 49416 break;
25553
25554 case left:
25555 101258 sx -= step;
25556 101258 x += step;
25557 101258 break;
25558
25559 case right:
25560 123767 sx += step;
25561 123767 x -= step;
25562 123767 break;
25563 }
25564
25565 //bound Hero when me move him off the screen in the last couple of frames of scrolling
25566
2/2
✓ Branch 0 taken 6810 times.
✓ Branch 1 taken 346051 times.
352861 if(y > 160) y = 160;
25567
25568
2/2
✓ Branch 0 taken 4196 times.
✓ Branch 1 taken 348665 times.
352861 if(y < 0) y = 0;
25569
25570
2/2
✓ Branch 0 taken 6308 times.
✓ Branch 1 taken 346553 times.
352861 if(x > 240) x = 240;
25571
25572
2/2
✓ Branch 0 taken 7712 times.
✓ Branch 1 taken 345149 times.
352861 if(x < 0) x = 0;
25573
25574
4/4
✓ Branch 0 taken 352615 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 352605 times.
352861 if(ladderx > 0 || laddery > 0)
25575 {
25576 // If the ladder moves on both axes, the player can
25577 // gradually shift it by going back and forth
25578
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
25579 laddery = y.getInt();
25580 else
25581 256 ladderx = x.getInt();
25582 256 }
25583 352861 }
25584
25585 //Drawing
25586 396731 tx = sx;
25587 396731 ty = sy;
25588 396731 tx2 = sx;
25589 396731 ty2 = sy;
25590
25591
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 126881 times.
✓ Branch 2 taken 62504 times.
✓ Branch 3 taken 103848 times.
✓ Branch 4 taken 103498 times.
396731 switch(scrolldir)
25592 {
25593 case right:
25594 126881 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
25595 126881 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25596 126881 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
25597 126881 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25598 126881 tx -= 256;
25599 126881 break;
25600
25601 case down:
25602 62504 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25603 62504 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
25604 62504 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25605 62504 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
25606 62504 ty -= 176;
25607 62504 break;
25608
25609 case left:
25610 103848 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
25611 103848 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25612 103848 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
25613 103848 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25614 103848 tx2 -= 256;
25615 103848 break;
25616
25617 case up:
25618 103498 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25619 103498 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
25620 103498 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25621 103498 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
25622 103498 ty2 -= 176;
25623 103498 break;
25624 }
25625
25626 //FFScript.OnWaitdraw()
25627 396731 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25628
25629 396731 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
25630 396731 clear_bitmap(scrollbuf);
25631 396731 clear_bitmap(framebuf);
25632
25633
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 103498 times.
✓ Branch 2 taken 62504 times.
✓ Branch 3 taken 103848 times.
✓ Branch 4 taken 126881 times.
396731 switch(scrolldir)
25634 {
25635 case up:
25636
1/2
✓ Branch 0 taken 103498 times.
✗ Branch 1 not taken.
103498 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25637
25638
1/2
✓ Branch 0 taken 103498 times.
✗ Branch 1 not taken.
103498 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
25639
25640
1/2
✓ Branch 0 taken 103498 times.
✗ Branch 1 not taken.
103498 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25641
25642
1/2
✓ Branch 0 taken 103498 times.
✗ Branch 1 not taken.
103498 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
25643
25644 // Draw both screens' background layer primitives together, after both layers' combos.
25645 // Not ideal, but probably good enough for all realistic purposes.
25646
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103498 times.
✓ Branch 2 taken 103498 times.
✗ Branch 3 not taken.
103498 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25647
25648
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103498 times.
✓ Branch 2 taken 103498 times.
✗ Branch 3 not taken.
103498 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25649
25650 103498 putscr(scrollbuf, 0, 0, newscr);
25651 103498 putscr(scrollbuf, 0, 176, oldscr);
25652 103498 break;
25653
25654 case down:
25655
1/2
✓ Branch 0 taken 62504 times.
✗ Branch 1 not taken.
62504 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
25656
25657
1/2
✓ Branch 0 taken 62504 times.
✗ Branch 1 not taken.
62504 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25658
25659
1/2
✓ Branch 0 taken 62504 times.
✗ Branch 1 not taken.
62504 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
25660
25661
1/2
✓ Branch 0 taken 62504 times.
✗ Branch 1 not taken.
62504 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25662
25663
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62504 times.
✓ Branch 2 taken 62504 times.
✗ Branch 3 not taken.
62504 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25664
25665
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62504 times.
✓ Branch 2 taken 62504 times.
✗ Branch 3 not taken.
62504 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25666
25667 62504 putscr(scrollbuf, 0, 0, oldscr);
25668 62504 putscr(scrollbuf, 0, 176, newscr);
25669 62504 break;
25670
25671 case left:
25672
2/2
✓ Branch 0 taken 103782 times.
✓ Branch 1 taken 66 times.
103848 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25673
25674
1/2
✓ Branch 0 taken 103848 times.
✗ Branch 1 not taken.
103848 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
25675
25676
1/2
✓ Branch 0 taken 103848 times.
✗ Branch 1 not taken.
103848 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25677
25678
1/2
✓ Branch 0 taken 103848 times.
✗ Branch 1 not taken.
103848 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
25679
25680
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 103782 times.
✓ Branch 2 taken 103782 times.
✓ Branch 3 taken 66 times.
103848 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25681
25682
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103848 times.
✓ Branch 2 taken 103848 times.
✗ Branch 3 not taken.
103848 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25683
25684 103848 putscr(scrollbuf, 0, 0, newscr);
25685 103848 putscr(scrollbuf, 256, 0, oldscr);
25686 103848 break;
25687
25688 case right:
25689
2/2
✓ Branch 0 taken 126815 times.
✓ Branch 1 taken 66 times.
126881 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
25690
25691
2/2
✓ Branch 0 taken 126815 times.
✓ Branch 1 taken 66 times.
126881 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25692
25693
1/2
✓ Branch 0 taken 126881 times.
✗ Branch 1 not taken.
126881 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
25694
25695
1/2
✓ Branch 0 taken 126881 times.
✗ Branch 1 not taken.
126881 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25696
25697
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 126815 times.
✓ Branch 2 taken 126749 times.
✓ Branch 3 taken 132 times.
126881 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25698
25699
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126881 times.
✓ Branch 2 taken 126881 times.
✗ Branch 3 not taken.
126881 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25700
25701 126881 putscr(scrollbuf, 0, 0, oldscr);
25702 126881 putscr(scrollbuf, 256, 0, newscr);
25703 126881 break;
25704 }
25705
25706 396731 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
25707 396731 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
25708
25709 396731 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
25710 396731 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
25711
25712
2/2
✓ Branch 0 taken 349314 times.
✓ Branch 1 taken 47417 times.
396731 if(get_bit(quest_rules, qr_FFCSCROLL))
25713 {
25714 47417 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
25715 47417 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
25716 47417 }
25717
25718
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 396665 times.
396731 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
25719
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 396599 times.
396731 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
25720
25721 //push blocks
25722 396731 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
25723 396731 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
25724
2/2
✓ Branch 0 taken 389545 times.
✓ Branch 1 taken 7186 times.
396731 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
25725 {
25726 7186 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
25727 7186 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
25728 7186 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
25729 7186 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
25730 7186 }
25731
25732 396731 do_walkflags(framebuf, oldscr, tx2, ty2,3); //show walkflags if the cheat is on
25733 396731 do_walkflags(framebuf, newscr, tx, ty,2);
25734
25735 396731 do_effectflags(framebuf, oldscr, tx2, ty2,3); //show effectflags if the cheat is on
25736 396731 do_effectflags(framebuf, newscr, tx, ty,2);
25737
25738
25739 396731 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
25740 396731 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
25741 396731 herostep();
25742
25743
5/6
✓ Branch 0 taken 396681 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396631 times.
✓ Branch 4 taken 396681 times.
✓ Branch 5 taken 396681 times.
396731 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
25744 {
25745 793312 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
25746 793312 }
25747
25748
4/4
✓ Branch 0 taken 238577 times.
✓ Branch 1 taken 158154 times.
✓ Branch 2 taken 124919 times.
✓ Branch 3 taken 113658 times.
396731 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
25749 {
25750 283073 draw_under(framebuf); //draw the ladder or raft
25751 283073 decorations.draw2(framebuf, true);
25752 283073 draw(framebuf); //Hero
25753 283073 decorations.draw(framebuf, true);
25754 283073 }
25755
25756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396731 times.
396731 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
25757
25758 396731 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
25759 396731 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
25760
2/2
✓ Branch 0 taken 392432 times.
✓ Branch 1 taken 4299 times.
396731 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25761 {
25762 4299 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
25763 4299 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
25764 4299 }
25765 396731 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
25766 396731 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
25767 396731 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
25768
25769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396731 times.
396731 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
25770
25771 396731 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
25772 396731 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
25773
2/2
✓ Branch 0 taken 392432 times.
✓ Branch 1 taken 4299 times.
396731 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25774 {
25775 4299 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
25776 4299 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
25777 4299 }
25778 396731 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
25779 396731 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
25780 396731 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
25781
25782
25783
1/2
✓ Branch 0 taken 396731 times.
✗ Branch 1 not taken.
396731 if(msg_bg_display_buf->clip == 0)
25784 {
25785 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25786 }
25787
1/2
✓ Branch 0 taken 396731 times.
✗ Branch 1 not taken.
396731 if(msg_portrait_display_buf->clip == 0)
25788 {
25789 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25790 }
25791
1/2
✓ Branch 0 taken 396731 times.
✗ Branch 1 not taken.
396731 if(msg_txt_display_buf->clip == 0)
25792 {
25793 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25794 }
25795
25796
6/6
✓ Branch 0 taken 10593 times.
✓ Branch 1 taken 386138 times.
✓ Branch 2 taken 10433 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 10416 times.
396731 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
25797 {
25798 177 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
25799 177 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
25800 177 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
25801 177 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
25802 177 calc_darkroom_combos(true);
25803 177 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
25804 177 }
25805
25806
4/4
✓ Branch 0 taken 10593 times.
✓ Branch 1 taken 386138 times.
✓ Branch 2 taken 7074 times.
✓ Branch 3 taken 3519 times.
396731 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
25807 {
25808 3519 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25809 3519 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25810 3519 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25811
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(newscr->flags & fDARK)
25812 {
25813 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25814 {
25815 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25816 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25817 }
25818
25819 color_map = &trans_table2;
25820 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25821 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25822 else
25823 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25824 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25825 color_map = &trans_table;
25826 }
25827
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(oldscr->flags & fDARK)
25828 {
25829 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25830 {
25831 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25832 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25833 }
25834
25835 color_map = &trans_table2;
25836 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25837 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25838 else
25839 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25840 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25841 color_map = &trans_table;
25842 }
25843 3519 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25844 3519 }
25845 396731 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
25846
2/2
✓ Branch 0 taken 221463 times.
✓ Branch 1 taken 175268 times.
396731 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
25847 175268 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
25848
25849
4/4
✓ Branch 0 taken 10593 times.
✓ Branch 1 taken 386138 times.
✓ Branch 2 taken 7074 times.
✓ Branch 3 taken 3519 times.
396731 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
25850 {
25851 7074 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25852 7074 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25853 7074 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25854
2/2
✓ Branch 0 taken 6914 times.
✓ Branch 1 taken 160 times.
7074 if(newscr->flags & fDARK)
25855 {
25856
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25857 {
25858 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25859 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25860 }
25861
25862 160 color_map = &trans_table2;
25863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25864 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25865 else
25866 160 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25867 160 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25868 160 color_map = &trans_table;
25869 160 }
25870
2/2
✓ Branch 0 taken 6931 times.
✓ Branch 1 taken 143 times.
7074 if(oldscr->flags & fDARK)
25871 {
25872
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25873 {
25874 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25875 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25876 }
25877
25878 143 color_map = &trans_table2;
25879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25880 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25881 else
25882 143 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25883 143 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25884 143 color_map = &trans_table;
25885 143 }
25886 7074 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25887 7074 }
25888 396731 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
25889
25890 //end drawing
25891 396731 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25892 396731 advanceframe(true/*,true,false*/);
25893 396731 script_drawing_commands.Clear();
25894 396731 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25895 396731 actiontype lastaction = action;
25896 396731 action=scrolling; FFCore.setHeroAction(scrolling);
25897 396731 FFCore.runF6Engine();
25898 //FFCore.runF6EngineScrolling(newscr,oldscr,tx,ty,tx2,ty2,sx,sy,scrolldir);
25899 396731 action=lastaction; FFCore.setHeroAction(lastaction);
25900 396731 }//end main scrolling loop (2 spaces tab width makes me sad =( )
25901 5493 currdmap = olddmap;
25902
25903 5493 clear_bitmap(msg_txt_display_buf);
25904 5493 set_clip_state(msg_txt_display_buf, 1);
25905 5493 clear_bitmap(msg_bg_display_buf);
25906 5493 set_clip_state(msg_bg_display_buf, 1);
25907 5493 clear_bitmap(msg_portrait_display_buf);
25908 5493 set_clip_state(msg_portrait_display_buf, 1);
25909
25910 //Move hero to the other side of the screen if scrolling's not turned on
25911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5493 times.
5493 if(get_bit(quest_rules, qr_NOSCROLL))
25912 {
25913 switch(scrolldir)
25914 {
25915 case up:
25916 y = 160;
25917 break;
25918
25919 case down:
25920 y = 0;
25921 break;
25922
25923 case left:
25924 x = 240;
25925 break;
25926
25927 case right:
25928 x = 0;
25929 break;
25930 }
25931 }
25932
25933
3/4
✓ Branch 0 taken 5492 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 5493 times.
✗ Branch 3 not taken.
5493 if((z > 0 || fakez > 0) && isSideViewHero())
25934 {
25935 y -= z;
25936 y -= fakez;
25937 z = 0;
25938 fakez = 0;
25939 }
25940
25941 5493 set_respawn_point(false);
25942 5493 trySideviewLadder();
25943 5493 warpx = -1;
25944 5493 warpy = -1;
25945
25946 5493 screenscrolling = false;
25947 5493 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
25948 5493 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25949 5493 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25950 5493 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25951 5493 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25952
25953
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 5349 times.
5493 if(destdmap != -1)
25954 {
25955 144 bool changedlevel = false;
25956 144 bool changeddmap = false;
25957
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 110 times.
144 if(olddmap != destdmap)
25958 {
25959 110 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25960 110 changeddmap = true;
25961 110 }
25962
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 77 times.
144 if(DMaps[olddmap].level != DMaps[destdmap].level)
25963 {
25964 77 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25965 77 changedlevel = true;
25966 77 }
25967 144 dlevel = DMaps[destdmap].level;
25968 144 currdmap = destdmap;
25969
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 110 times.
144 if(changeddmap)
25970 {
25971 110 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25972 110 }
25973
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 77 times.
144 if(changedlevel)
25974 {
25975 77 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25976 77 }
25977 144 }
25978
25979 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
25980 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
25981 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
25982 //direction. -DD
25983
25984
2/2
✓ Branch 0 taken 5428 times.
✓ Branch 1 taken 65 times.
5493 if(nowinwater)
25985 {
25986 65 SetSwim();
25987 65 hopclk = 0xFF;
25988 65 }
25989
25990 // NES behaviour: Fade to light after scrolling
25991 5493 lighting(false, false); // No, we don't need to set naturaldark...
25992
25993 5493 init_dmap();
25994 5493 putscr(scrollbuf,0,0,newscr);
25995 5493 putscrdoors(scrollbuf,0,0,newscr);
25996
25997 // Check for raft flags
25998
6/6
✓ Branch 0 taken 5406 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 5341 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 5290 times.
5493 if(action!=rafting && hopclk==0 && !toogam)
25999 {
26000
3/4
✓ Branch 0 taken 5287 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5287 times.
5290 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
26001 {
26002 3 sfx(tmpscr->secretsfx);
26003 3 action=rafting; FFCore.setHeroAction(rafting);
26004 3 raftclk=0;
26005 3 }
26006
26007 // Half a tile off?
26008
6/8
✓ Branch 0 taken 3911 times.
✓ Branch 1 taken 1376 times.
✓ Branch 2 taken 1603 times.
✓ Branch 3 taken 2308 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2979 times.
✓ Branch 6 taken 5287 times.
✗ Branch 7 not taken.
8266 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
26009 {
26010 sfx(tmpscr->secretsfx);
26011 action=rafting; FFCore.setHeroAction(rafting);
26012 raftclk=0;
26013 }
26014 5290 }
26015
26016 5493 opendoors=0;
26017 5493 markBmap(-1);
26018
26019
2/2
✓ Branch 0 taken 3075 times.
✓ Branch 1 taken 2418 times.
5493 if(isdungeon())
26020 {
26021
3/3
✓ Branch 0 taken 1350 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 468 times.
2418 switch(tmpscr->door[scrolldir^1])
26022 {
26023 case dOPEN:
26024 case dUNLOCKED:
26025 case dOPENBOSS:
26026 1350 dir = scrolldir;
26027
26028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1350 times.
1350 if(action!=rafting)
26029 1350 stepforward(diagonalMovement?11:12, false);
26030
26031 1350 break;
26032
26033 case dSHUTTER:
26034 case d1WAYSHUTTER:
26035 600 dir = scrolldir;
26036
26037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
600 if(action!=rafting)
26038 600 stepforward(diagonalMovement?21:24, false);
26039
26040 600 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
26041 600 opendoors=-4;
26042 600 sfx(WAV_DOOR);
26043 600 break;
26044
26045 default:
26046 468 dir = scrolldir;
26047
26048
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 421 times.
468 if(action!=rafting)
26049 421 stepforward(diagonalMovement?21:24, false);
26050 468 }
26051 2418 }
26052
26053
1/2
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
5493 if(action == scrolling)
26054 {
26055 action=none; FFCore.setHeroAction(none);
26056 }
26057
26058
2/4
✓ Branch 0 taken 5493 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5493 times.
5493 if(action != attacking && action != sideswimattacking)
26059 {
26060 5493 charging = 0;
26061 5493 tapping = false;
26062 5493 }
26063
26064 5493 map_bkgsfx(true);
26065
26066
2/2
✓ Branch 0 taken 5475 times.
✓ Branch 1 taken 18 times.
5493 if(newscr->flags2&fSECRET)
26067 {
26068 18 sfx(newscr->secretsfx);
26069 18 }
26070
26071 5493 playLevelMusic();
26072
26073 5493 newscr_clk = frame;
26074 5493 activated_timed_warp=false;
26075 5493 loadside = scrolldir^1;
26076 5493 FFCore.init_combo_doscript();
26077 5493 eventlog_mapflags();
26078 5493 decorations.animate(); //continue to animate tall grass during scrolling
26079
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 5278 times.
5493 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
26080 {
26081 //script_drawing_commands.Clear();
26082 215 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
26083 //ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
26084 215 }
26085 5493 }
26086
26087
26088
26089 // How much to reduce Hero's damage, taking into account various rings.
26090 4636 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
26091 {
26092
1/2
✓ Branch 0 taken 4636 times.
✗ Branch 1 not taken.
4636 if(dmg < 0) return dmg; //Don't reduce healing
26093
2/2
✓ Branch 0 taken 4506 times.
✓ Branch 1 taken 130 times.
4636 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
26094 {
26095 4506 int32_t divisor = 1;
26096 4506 float percentage = 1;
26097 4506 int32_t itemid = current_item_id(itype_ring);
26098 4506 bool usering = false;
26099
26100
4/4
✓ Branch 0 taken 3362 times.
✓ Branch 1 taken 1144 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3334 times.
4506 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26101 {
26102 3334 usering = true;
26103 3334 paymagiccost(itemid);
26104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3334 times.
3334 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26105 {
26106 percentage *= itemsbuf[itemid].power/100.0;
26107 }
26108 else
26109 {
26110 3334 divisor *= itemsbuf[itemid].power;
26111 }
26112 3334 }
26113
26114 /* Now for the Peril Ring */
26115 4506 itemid = current_item_id(itype_perilring);
26116
26117
7/10
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 4072 times.
✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
4506 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26118 {
26119 7 usering = true;
26120 7 paymagiccost(itemid);
26121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26122 {
26123 percentage *= itemsbuf[itemid].power/100.0;
26124 }
26125 else
26126 {
26127 7 divisor *= itemsbuf[itemid].power;
26128 }
26129 7 }
26130
26131 // Ring divisor of 0 = no damage. -L
26132
4/6
✓ Branch 0 taken 3341 times.
✓ Branch 1 taken 1165 times.
✓ Branch 2 taken 3341 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3341 times.
4506 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26133 return 0;
26134
26135
1/2
✓ Branch 0 taken 4506 times.
✗ Branch 1 not taken.
4506 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
26136
26137
1/2
✓ Branch 0 taken 4506 times.
✗ Branch 1 not taken.
4506 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
26138
1/2
✓ Branch 0 taken 4506 times.
✗ Branch 1 not taken.
4506 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26139
26140 }
26141 else
26142 {
26143 130 double divisor = 1;
26144 130 double percentage = 1;
26145 130 int32_t itemid = current_item_id(itype_ring);
26146 130 bool usering = false;
26147
26148
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
130 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26149 {
26150 1 usering = true;
26151 1 paymagiccost(itemid);
26152
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26153 {
26154 1 double perc = itemsbuf[itemid].power/100.0;
26155
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26156 1 percentage *= perc;
26157 1 }
26158 else
26159 {
26160 if(itemsbuf[itemid].power < 0)
26161 divisor /= -(itemsbuf[itemid].power);
26162 else divisor *= itemsbuf[itemid].power;
26163 }
26164 1 }
26165
26166 /* Now for the Peril Ring */
26167 130 itemid = current_item_id(itype_perilring);
26168
26169
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
130 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26170 {
26171 usering = true;
26172 paymagiccost(itemid);
26173 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26174 {
26175 double perc = itemsbuf[itemid].power/100.0;
26176 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26177 percentage *= perc;
26178 }
26179 else
26180 {
26181 if(itemsbuf[itemid].power < 0)
26182 divisor /= -(itemsbuf[itemid].power);
26183 else divisor *= itemsbuf[itemid].power;
26184 }
26185 }
26186
26187 // Ring divisor of 0 = no damage. -L
26188
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
130 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26189 return 0;
26190
26191 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
26192
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26193 }
26194 4636 }
26195
26196 // Should swinging the hammer make the 'pound' sound?
26197 // Or is Hero just hitting air?
26198 258 bool HeroClass::sideviewhammerpound()
26199 {
26200 258 int32_t wx=0,wy=0;
26201
26202
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 114 times.
258 switch(dir)
26203 {
26204 case up:
26205 81 wx=-1;
26206 81 wy=-15;
26207
26208
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(isSideViewHero()) wy+=8;
26209
26210 81 break;
26211
26212 case down:
26213 51 wx=8;
26214 51 wy=28;
26215
26216
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(isSideViewHero()) wy-=8;
26217
26218 51 break;
26219
26220 case left:
26221 12 wx=-8;
26222 12 wy=14;
26223
26224
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(isSideViewHero()) wy+=8;
26225
26226 12 break;
26227
26228 case right:
26229 114 wx=21;
26230 114 wy=14;
26231
26232
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(isSideViewHero()) wy+=8;
26233
26234 114 break;
26235 }
26236
26237
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 252 times.
258 if(!isSideViewHero())
26238 {
26239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
26240 }
26241
26242
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26243
26244 if(dir==left || dir==right)
26245 {
26246 wx+=16;
26247
26248 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26249 }
26250
26251 return false;
26252 258 }
26253
26254 /************************************/
26255 /******** More Items Code *********/
26256 /************************************/
26257
26258 // The following are only used for Hero damage. Damage is in quarter hearts.
26259 2464 int32_t enemy_dp(int32_t index)
26260 {
26261 2464 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
26262 }
26263
26264 2055 int32_t ewpn_dp(int32_t index)
26265 {
26266 2055 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
26267 }
26268
26269 18 int32_t lwpn_dp(int32_t index)
26270 {
26271 18 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
26272 }
26273
26274 53129367 bool checkbunny(int32_t itemid)
26275 {
26276
1/4
✓ Branch 0 taken 53129367 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53129367 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
26277 }
26278
26279 12791669 bool usesSwordJinx(int32_t itemid)
26280 {
26281 12791669 itemdata const& it = itemsbuf[itemid];
26282 12791669 bool ret = (it.family==itype_sword);
26283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12791669 times.
12791669 if(it.flags & ITEM_FLIP_JINX) return !ret;
26284 12791669 return ret;
26285 12791669 }
26286 10956834 bool checkitem_jinx(int32_t itemid)
26287 {
26288 10956834 itemdata const& it = itemsbuf[itemid];
26289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10956834 times.
10956834 if(it.flags & ITEM_JINX_IMMUNE) return true;
26290
2/2
✓ Branch 0 taken 3250379 times.
✓ Branch 1 taken 7706455 times.
10956834 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
26291 7706455 return HeroItemClk() == 0;
26292 10956834 }
26293
26294 209612 int32_t Bweapon(int32_t pos)
26295 {
26296
4/4
✓ Branch 0 taken 209611 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 622 times.
✓ Branch 3 taken 208989 times.
209612 if(pos < 0 || current_subscreen_active == NULL)
26297 {
26298 623 return 0;
26299 }
26300
26301 208989 int32_t p=-1;
26302
26303
4/4
✓ Branch 0 taken 58553 times.
✓ Branch 1 taken 6068123 times.
✓ Branch 2 taken 58553 times.
✓ Branch 3 taken 6068123 times.
6126676 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
26304 {
26305
4/4
✓ Branch 0 taken 4317930 times.
✓ Branch 1 taken 1750193 times.
✓ Branch 2 taken 4167494 times.
✓ Branch 3 taken 150436 times.
6068123 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
26306 {
26307 150436 p=i;
26308 150436 break;
26309 }
26310 5917687 }
26311
26312
2/2
✓ Branch 0 taken 150436 times.
✓ Branch 1 taken 58553 times.
208989 if(p==-1)
26313 {
26314 58553 return 0;
26315 }
26316
26317 150436 int32_t actualItem = current_subscreen_active->objects[p].d8;
26318 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
26319 150436 int32_t family = -1;
26320 150436 bool bow = false;
26321
26322
2/2
✓ Branch 0 taken 9469 times.
✓ Branch 1 taken 140967 times.
150436 if(actualItem)
26323 {
26324 9469 bool select = false;
26325
26326
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3247 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6222 times.
9469 switch(itemsbuf[actualItem-1].family)
26327 {
26328 case itype_bomb:
26329 if((game->get_bombs() ||
26330 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26331 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
26332 current_item_power(itype_bombbag))
26333 {
26334 select=true;
26335 }
26336
26337 break;
26338
26339 case itype_bowandarrow:
26340 case itype_arrow:
26341 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
26342 {
26343 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26344 select=true;
26345 }
26346
26347 break;
26348
26349 case itype_letterpotion:
26350 /*if(current_item_id(itype_potion)>-1)
26351 {
26352 select=true;
26353 }
26354 else if(current_item_id(itype_letter)>-1)
26355 {
26356 select=true;
26357 }*/
26358 break;
26359
26360 case itype_sbomb:
26361 {
26362 int32_t bombbagid = current_item_id(itype_bombbag);
26363
26364 if((game->get_sbombs() ||
26365 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26366 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
26367 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26368 {
26369 select=true;
26370 }
26371
26372 break;
26373 }
26374
26375 case itype_sword:
26376 {
26377
1/2
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
6222 if(!get_bit(quest_rules,qr_SELECTAWPN))
26378 break;
26379
26380 6222 select=true;
26381 }
26382 6222 break;
26383
26384 default:
26385 3247 select=true;
26386 3247 }
26387
26388
4/6
✓ Branch 0 taken 9469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✓ Branch 3 taken 1850 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7619 times.
9469 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
26389 {
26390 7619 directItem = actualItem-1;
26391
26392
2/4
✓ Branch 0 taken 7619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✗ Branch 3 not taken.
7619 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
26393
26394 7619 return actualItem-1+(bow?0xF000:0);
26395 }
26396 1850 else return 0;
26397 }
26398
26399 140967 directItem = -1;
26400
26401
6/6
✓ Branch 0 taken 15300 times.
✓ Branch 1 taken 1546 times.
✓ Branch 2 taken 115064 times.
✓ Branch 3 taken 5986 times.
✓ Branch 4 taken 2584 times.
✓ Branch 5 taken 487 times.
140967 switch(current_subscreen_active->objects[p].d1)
26402 {
26403 case itype_bomb:
26404 {
26405 15300 int32_t bombid = current_item_id(itype_bomb);
26406
26407
3/4
✓ Branch 0 taken 4874 times.
✓ Branch 1 taken 10426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4874 times.
20174 if((game->get_bombs() ||
26408 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26409
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 4849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
4874 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
26410 4874 current_item_power(itype_bombbag))
26411 {
26412 10426 family=itype_bomb;
26413 10426 }
26414
26415 15300 break;
26416 }
26417
26418 case itype_bowandarrow:
26419 case itype_arrow:
26420
4/4
✓ Branch 0 taken 4991 times.
✓ Branch 1 taken 995 times.
✓ Branch 2 taken 4990 times.
✓ Branch 3 taken 1 times.
5986 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
26421 {
26422 4990 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26423 4990 family=itype_arrow;
26424 4990 }
26425
26426 5986 break;
26427
26428 case itype_letterpotion:
26429
2/2
✓ Branch 0 taken 1424 times.
✓ Branch 1 taken 1160 times.
2584 if(current_item_id(itype_potion)>-1)
26430 {
26431 1424 family=itype_potion;
26432 1424 }
26433
2/2
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 272 times.
1160 else if(current_item_id(itype_letter)>-1)
26434 {
26435 272 family=itype_letter;
26436 272 }
26437
26438 2584 break;
26439
26440 case itype_sbomb:
26441 {
26442 1546 int32_t bombbagid = current_item_id(itype_bombbag);
26443 1546 int32_t sbombid = current_item_id(itype_sbomb);
26444
26445
2/4
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 972 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1546 if((game->get_sbombs() ||
26446 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
574 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
26448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
574 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26449 {
26450 972 family=itype_sbomb;
26451 972 }
26452
26453 1546 break;
26454 }
26455
26456 case itype_sword:
26457 {
26458
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 30 times.
487 if(!get_bit(quest_rules,qr_SELECTAWPN))
26459 30 break;
26460
26461 457 family=itype_sword;
26462 }
26463 457 break;
26464
26465 default:
26466 115064 family=current_subscreen_active->objects[p].d1;
26467 115064 }
26468
26469
2/2
✓ Branch 0 taken 133605 times.
✓ Branch 1 taken 7362 times.
140967 if(family==-1)
26470 7362 return 0;
26471
26472
2/2
✓ Branch 0 taken 6702522 times.
✓ Branch 1 taken 11199 times.
6713721 for(int32_t j=0; j<MAXITEMS; j++)
26473 {
26474 // Find the item that matches this subscreen object.
26475
5/6
✓ Branch 0 taken 210714 times.
✓ Branch 1 taken 6491808 times.
✓ Branch 2 taken 122406 times.
✓ Branch 3 taken 88308 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 122406 times.
6702522 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
26476 {
26477 122406 return j+(bow?0xF000:0);
26478 }
26479 6580116 }
26480
26481 11199 return 0;
26482 209612 }
26483
26484 93 int32_t BWeapon_to_Pos(int32_t bweapon)
26485 {
26486
2/2
✓ Branch 0 taken 5272 times.
✓ Branch 1 taken 19 times.
5291 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
26487 {
26488
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5198 times.
5272 if (Bweapon(i) == bweapon)
26489 {
26490 74 return i;
26491 }
26492 5198 }
26493 19 return -1;
26494 93 }
26495
26496 void stopCaneOfByrna()
26497 {
26498 for(int32_t i=0; i<Lwpns.Count(); i++)
26499 {
26500 weapon *w = ((weapon*)Lwpns.spr(i));
26501 if(w->id==wCByrna)
26502 w->dead=1;
26503 }
26504 }
26505
26506 /* Crashes if used by ffscript.cpp, in case LINKITEMD
26507 void stopCaneOfByrna()
26508 {
26509 byte prnt_cane = -1;
26510 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
26511 prnt_cane = ew->parentitem;
26512 for(int32_t i=0; i<Lwpns.Count(); i++)
26513 {
26514 weapon *w = ((weapon*)Lwpns.spr(i));
26515
26516 if(w->id==wCByrna)
26517 {
26518 w->dead=1;
26519 }
26520 }
26521 if ( prnt_cane > -1 )
26522 {
26523 stop_sfx(itemsbuf[prnt_cane].usesound);
26524 }
26525 }
26526 */
26527 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
26528 3627373 void HeroClass::cleanupByrna()
26529 {
26530
1/2
✓ Branch 0 taken 3627373 times.
✗ Branch 1 not taken.
3627373 if ( last_cane_of_byrna_item_id > -1 )
26531 {
26532 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
26533 if ( !(Lwpns.idCount(wCByrna)) )
26534 {
26535 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
26536 last_cane_of_byrna_item_id = -1;
26537 }
26538 }
26539 3627373 }
26540
26541 // Used to find out if an item family is attached to one of the buttons currently pressed.
26542 1450864 bool isWpnPressed(int32_t itype)
26543 {
26544 //0xFFF for subscreen overrides
26545 //Will crash on win10 without it! -Z
26546
4/4
✓ Branch 0 taken 206573 times.
✓ Branch 1 taken 1244291 times.
✓ Branch 2 taken 181624 times.
✓ Branch 3 taken 24949 times.
1450864 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
26547
4/4
✓ Branch 0 taken 498864 times.
✓ Branch 1 taken 927051 times.
✓ Branch 2 taken 149071 times.
✓ Branch 3 taken 349793 times.
1425915 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
26548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1076122 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1076122 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
26549
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1076102 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
1076122 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
26550 1076102 return false;
26551 1450864 }
26552
26553 3506178 int32_t getWpnPressed(int32_t itype)
26554 {
26555
4/4
✓ Branch 0 taken 175696 times.
✓ Branch 1 taken 3330482 times.
✓ Branch 2 taken 170571 times.
✓ Branch 3 taken 5125 times.
3506178 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26556
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3500467 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
3501053 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3500467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3500467 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3500467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3500467 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26559
26560 3500467 return -1;
26561 3506178 }
26562
26563 3628965 int32_t getRocsPressed()
26564 {
26565 3628965 int32_t jumpid = current_item_id(itype_rocs,true,true);
26566
26567
2/2
✓ Branch 0 taken 185339 times.
✓ Branch 1 taken 3443626 times.
3628965 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
26568
26569
2/2
✓ Branch 0 taken 3443626 times.
✓ Branch 1 taken 185339 times.
3628965 if (jumpid != -1)
26570 {
26571 185339 itemdata const& itm = itemsbuf[jumpid];
26572
26573 185339 byte intbtn = byte(itm.misc2&0xFF);
26574
1/2
✓ Branch 0 taken 185339 times.
✗ Branch 1 not taken.
185339 if(getIntBtnInput(intbtn, false, true, false, false, true))
26575 return jumpid; //not pressed
26576 185339 }
26577
26578
4/4
✓ Branch 0 taken 15394 times.
✓ Branch 1 taken 3613571 times.
✓ Branch 2 taken 14327 times.
✓ Branch 3 taken 1067 times.
3628965 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26579
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3627898 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3627898 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26580
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3627898 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3627898 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26581
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3627898 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3627898 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26582
26583 3627898 return -1;
26584 3628965 }
26585
26586 bool isItmPressed(int32_t itmid)
26587 {
26588 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
26589 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
26590 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
26591 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
26592 return false;
26593 }
26594
26595 781 void selectNextAWpn(int32_t type)
26596 {
26597
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(!get_bit(quest_rules,qr_SELECTAWPN))
26598 return;
26599
26600
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
781 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26601 781 Awpn = Bweapon(ret);
26602 781 directItemA = directItem;
26603 781 game->awpn = ret;
26604 781 }
26605
26606 4157 void selectNextBWpn(int32_t type)
26607 {
26608
2/4
✓ Branch 0 taken 4157 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4157 times.
4157 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26609 4157 Bwpn = Bweapon(ret);
26610 4157 directItemB = directItem;
26611 4157 game->bwpn = ret;
26612 4157 }
26613
26614 void selectNextXWpn(int32_t type)
26615 {
26616 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
26617 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26618 Xwpn = Bweapon(ret);
26619 directItemX = directItem;
26620 game->xwpn = ret;
26621 }
26622
26623 void selectNextYWpn(int32_t type)
26624 {
26625 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
26626 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
26627 Ywpn = Bweapon(ret);
26628 directItemY = directItem;
26629 game->ywpn = ret;
26630 }
26631
26632 28767 void verifyAWpn()
26633 {
26634
2/2
✓ Branch 0 taken 1021 times.
✓ Branch 1 taken 27746 times.
28767 if ( (game->forced_awpn != -1) )
26635 {
26636 1021 return;
26637 }
26638
2/2
✓ Branch 0 taken 25086 times.
✓ Branch 1 taken 2660 times.
27746 if(!get_bit(quest_rules,qr_SELECTAWPN))
26639 {
26640 25086 Awpn = selectSword();
26641 25086 game->awpn = 0xFF;
26642 25086 }
26643 else
26644 {
26645 2660 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
26646 2660 Awpn = Bweapon(game->awpn);
26647 2660 directItemA = directItem;
26648 }
26649 28767 }
26650
26651 27257 void verifyBWpn()
26652 {
26653
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 26242 times.
27257 if ( (game->forced_bwpn != -1) )
26654 {
26655 1015 return;
26656 }
26657 26242 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
26658 26242 Bwpn = Bweapon(game->bwpn);
26659 26242 directItemB = directItem;
26660 27257 }
26661
26662 27257 void verifyXWpn()
26663 {
26664
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 26242 times.
27257 if ( (game->forced_xwpn != -1) )
26665 {
26666 1015 return;
26667 }
26668
2/2
✓ Branch 0 taken 26178 times.
✓ Branch 1 taken 64 times.
26242 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
26669 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
26670 26178 else game->xwpn = -1;
26671 26242 Xwpn = Bweapon(game->xwpn);
26672 26242 directItemX = directItem;
26673 27257 }
26674
26675 27257 void verifyYWpn()
26676 {
26677
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 26242 times.
27257 if ( (game->forced_ywpn != -1) )
26678 {
26679 1015 return;
26680 }
26681
2/2
✓ Branch 0 taken 26178 times.
✓ Branch 1 taken 64 times.
26242 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
26682 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
26683 26178 else game->ywpn = -1;
26684 26242 Ywpn = Bweapon(game->ywpn);
26685 26242 directItemY = directItem;
26686 27257 }
26687
26688 27257 void verifyBothWeapons()
26689 {
26690 27257 verifyAWpn();
26691 27257 verifyBWpn();
26692 27257 verifyXWpn();
26693 27257 verifyYWpn();
26694 27257 }
26695
26696 35158 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
26697 {
26698 //what will be returned when all else fails.
26699 //don't return the forbiddenpos... no matter what -DD
26700
26701 35158 int32_t failpos(0);
26702
26703
6/6
✓ Branch 0 taken 34424 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 34287 times.
✓ Branch 3 taken 137 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 34283 times.
35158 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
26704 875 failpos = 0xFF;
26705 34283 else failpos = startpos;
26706
26707 // verify startpos
26708
3/4
✓ Branch 0 taken 35158 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✓ Branch 3 taken 34273 times.
35158 if(startpos < 0 || startpos >= 0xFF)
26709 885 startpos = 0;
26710
26711
2/2
✓ Branch 0 taken 34940 times.
✓ Branch 1 taken 218 times.
35158 if(current_subscreen_active == NULL)
26712 218 return failpos;
26713
26714
4/4
✓ Branch 0 taken 6035 times.
✓ Branch 1 taken 28905 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 5564 times.
34940 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
26715 {
26716 29376 int32_t wpn = Bweapon(startpos);
26717
26718
6/8
✓ Branch 0 taken 27859 times.
✓ Branch 1 taken 1517 times.
✓ Branch 2 taken 27855 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 27855 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 27855 times.
29376 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
26719 {
26720 27855 return startpos;
26721 }
26722 1521 }
26723
26724 7085 int32_t p=-1;
26725 7085 int32_t curpos = startpos;
26726 7085 int32_t firstValidPos=-1;
26727
26728
2/2
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 161319 times.
162063 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26729 {
26730
2/2
✓ Branch 0 taken 46201 times.
✓ Branch 1 taken 115118 times.
161319 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26731 {
26732
4/4
✓ Branch 0 taken 86208 times.
✓ Branch 1 taken 28910 times.
✓ Branch 2 taken 79867 times.
✓ Branch 3 taken 6341 times.
115118 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
26733 {
26734 6341 firstValidPos=i;
26735 6341 }
26736
26737
2/2
✓ Branch 0 taken 108777 times.
✓ Branch 1 taken 6341 times.
115118 if(current_subscreen_active->objects[i].d3==curpos)
26738 {
26739 6341 p=i;
26740 6341 break;
26741 }
26742 108777 }
26743 154978 }
26744
26745
2/2
✓ Branch 0 taken 6341 times.
✓ Branch 1 taken 744 times.
7085 if(p == -1)
26746 {
26747 //can't find the current position
26748 // Switch to a valid weapon if there is one; otherwise,
26749 // the selector can simply disappear
26750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744 times.
744 if(firstValidPos>=0)
26751 {
26752 return current_subscreen_active->objects[firstValidPos].d3;
26753 }
26754 //FAILURE
26755 else
26756 {
26757 744 return failpos;
26758 }
26759 }
26760
26761 //remember we've been here
26762 6341 set<int32_t> oldPositions;
26763
1/2
✓ Branch 0 taken 6341 times.
✗ Branch 1 not taken.
6341 oldPositions.insert(curpos);
26764
26765 //1. Perform any shifts required by the above
26766 //2. If that's not possible, go to position 1 and reset the b weapon.
26767 //2a. -if we arrive at a position we've already visited, give up and stay there
26768 //3. Get the weapon at the new slot
26769 //4. If it's not possible, go to step 1.
26770
26771 21609 for(;;)
26772 {
26773 //shift
26774
4/5
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 18863 times.
✗ Branch 4 not taken.
21609 switch(type)
26775 {
26776 case SEL_LEFT:
26777 case SEL_VERIFY_LEFT:
26778 2685 curpos = current_subscreen_active->objects[p].d6;
26779 2685 break;
26780
26781 case SEL_RIGHT:
26782 case SEL_VERIFY_RIGHT:
26783 18863 curpos = current_subscreen_active->objects[p].d7;
26784 18863 break;
26785
26786 case SEL_DOWN:
26787 14 curpos = current_subscreen_active->objects[p].d5;
26788 14 break;
26789
26790 case SEL_UP:
26791 47 curpos = current_subscreen_active->objects[p].d4;
26792 47 break;
26793 }
26794
26795 //find our new position
26796 21609 p = -1;
26797
26798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 718548 times.
718548 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26799 {
26800
2/2
✓ Branch 0 taken 154322 times.
✓ Branch 1 taken 564226 times.
718548 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26801 {
26802
2/2
✓ Branch 0 taken 542617 times.
✓ Branch 1 taken 21609 times.
564226 if(current_subscreen_active->objects[i].d3==curpos)
26803 {
26804 21609 p=i;
26805 21609 break;
26806 }
26807 542617 }
26808 696939 }
26809
26810
1/2
✓ Branch 0 taken 21609 times.
✗ Branch 1 not taken.
21609 if(p == -1)
26811 {
26812 //can't find the current position
26813 //FAILURE
26814 return failpos;
26815 }
26816
26817 //if we've already been here, give up
26818
3/4
✓ Branch 0 taken 21609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20570 times.
✓ Branch 3 taken 1039 times.
21609 if(oldPositions.find(curpos) != oldPositions.end())
26819 {
26820 1039 return failpos;
26821 }
26822
26823 //else, remember we've been here
26824
1/2
✓ Branch 0 taken 20570 times.
✗ Branch 1 not taken.
20570 oldPositions.insert(curpos);
26825
26826 //see if this weapon is acceptable
26827
9/10
✓ Branch 0 taken 20570 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5531 times.
✓ Branch 3 taken 15039 times.
✓ Branch 4 taken 5320 times.
✓ Branch 5 taken 211 times.
✓ Branch 6 taken 5310 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 5302 times.
20570 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
26828 5302 return curpos;
26829
26830 //keep going otherwise
26831 }
26832 35158 }
26833
26834 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
26835 25171 int32_t selectSword()
26836 {
26837 25171 auto ret = current_item_id(itype_sword);
26838
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 24717 times.
25171 if(ret == -1) return 0;
26839 24717 return ret;
26840 25171 }
26841
26842 // Adding code here for allowing hardcoding a button to a specific itemclass.
26843 int32_t selectItemclass(int32_t itemclass)
26844 {
26845 int32_t ret = current_item_id(itemclass);
26846
26847 if(ret == -1)
26848 ret = 0;
26849
26850 return ret;
26851 }
26852
26853 // Used for the 'Pickup Hearts' item pickup condition.
26854 54 bool canget(int32_t id)
26855 {
26856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
26857 }
26858
26859 24 void dospecialmoney(int32_t index)
26860 {
26861 24 int32_t tmp=currscr>=128?1:0;
26862 24 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
26863
26864
3/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
24 switch(tmpscr[tmp].room)
26865 {
26866 case rINFO: // pay for info
26867 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
26868 {
26869
26870
26871 if(!current_item_power(itype_wallet))
26872 {
26873 if (game->get_spendable_rupies() < abs(prices[priceindex]))
26874 return;
26875 int32_t tmpprice = -abs(prices[priceindex]);
26876 int32_t total = game->get_drupy()-tmpprice;
26877 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26878 game->set_drupy(game->get_drupy()-total);
26879 //game->change_drupy(-abs(prices[priceindex]));
26880 }
26881 if ( current_item_power(itype_wallet)>0 )
26882 {
26883 game->change_drupy(0);
26884 }
26885 }
26886 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
26887 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
26888 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
26889 clear_bitmap(pricesdisplaybuf);
26890 set_clip_state(pricesdisplaybuf, 1);
26891 items.del(0);
26892
26893 for(int32_t i=0; i<items.Count(); i++)
26894 ((item*)items.spr(i))->pickup=ipDUMMY;
26895
26896 // Prevent the prices from being displayed anymore
26897 for(int32_t i=0; i<3; i++)
26898 {
26899 prices[i] = 0;
26900 }
26901
26902 break;
26903
26904 case rMONEY: // secret money
26905 {
26906 11 ((item*)items.spr(0))->pickup = ipDUMMY;
26907
26908 11 prices[0] = tmpscr[tmp].catchall;
26909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!current_item_power(itype_wallet))
26910 11 game->change_drupy(prices[0]);
26911 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
26912
26913 11 putprices(false);
26914
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26915 11 break;
26916 }
26917
26918 case rGAMBLE: // gamble
26919 {
26920 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
26921
26922 unsigned si=(zc_oldrand()%24)*3;
26923
26924 for(int32_t i=0; i<3; i++)
26925 prices[i]=gambledat[si++];
26926
26927 game->set_drupy(game->get_drupy()+prices[priceindex]);
26928 putprices(true);
26929
26930 for(int32_t i=1; i<4; i++)
26931 ((item*)items.spr(i))->pickup=ipDUMMY;
26932 }
26933 break;
26934
26935 case rBOMBS:
26936 {
26937
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26938 return;
26939
26940 3 int32_t price = -tmpscr[tmp].catchall;
26941 3 int32_t wmedal = current_item_id(itype_wealthmedal);
26942
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(wmedal >= 0)
26943 {
26944 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26945 price*=(itemsbuf[wmedal].misc1/100.0);
26946 else
26947 price+=itemsbuf[wmedal].misc1;
26948 }
26949
26950 3 int32_t total = game->get_drupy()-price;
26951 3 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26952 3 game->set_drupy(game->get_drupy()-total);
26953 //game->set_drupy(game->get_drupy()+price);
26954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26955 3 game->change_maxbombs(4);
26956 3 game->set_bombs(game->get_maxbombs());
26957 {
26958 3 int32_t div = zinit.bomb_ratio;
26959
26960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(div > 0)
26961 3 game->change_maxcounter(4/div, 6);
26962 }
26963
26964 //also give Hero an actual Bomb item
26965
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
26966 {
26967
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 763 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
768 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
26968 3 getitem(i, true, true);
26969 768 }
26970
26971 3 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
26972 3 fadeclk=66;
26973 3 dismissmsg();
26974 3 clear_bitmap(pricesdisplaybuf);
26975 3 set_clip_state(pricesdisplaybuf, 1);
26976 // putscr(scrollbuf,0,0,tmpscr);
26977 3 verifyBothWeapons();
26978 3 break;
26979 }
26980
26981 case rARROWS:
26982 {
26983 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26984 return;
26985
26986 int32_t price = -tmpscr[tmp].catchall;
26987 int32_t wmedal = current_item_id(itype_wealthmedal);
26988 if(wmedal >= 0)
26989 {
26990 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26991 price*=(itemsbuf[wmedal].misc1/100.0);
26992 else
26993 price+=itemsbuf[wmedal].misc1;
26994 }
26995
26996 int32_t total = game->get_drupy()-price;
26997 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26998 game->set_drupy(game->get_drupy()-total);
26999
27000 //game->set_drupy(game->get_drupy()+price);
27001 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27002 game->change_maxarrows(10);
27003 game->set_arrows(game->get_maxarrows());
27004 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27005 fadeclk=66;
27006 dismissmsg();
27007 clear_bitmap(pricesdisplaybuf);
27008 set_clip_state(pricesdisplaybuf, 1);
27009 // putscr(scrollbuf,0,0,tmpscr);
27010 verifyBothWeapons();
27011 break;
27012 }
27013
27014 case rSWINDLE:
27015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(items.spr(index)->id==iRupy)
27016 {
27017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27018 return;
27019 10 int32_t tmpprice = -tmpscr[tmp].catchall;
27020 10 int32_t total = game->get_drupy()-tmpprice;
27021 10 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27022 10 game->set_drupy(game->get_drupy()-total);
27023 10 }
27024 else
27025 {
27026 if(game->get_maxlife()<=game->get_hp_per_heart())
27027 return;
27028
27029 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
27030 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
27031 }
27032
27033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27034 10 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
27035 10 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
27036 10 fadeclk=66;
27037 10 dismissmsg();
27038 10 clear_bitmap(pricesdisplaybuf);
27039 10 set_clip_state(pricesdisplaybuf, 1);
27040 // putscr(scrollbuf,0,0,tmpscr);
27041 10 break;
27042 }
27043 24 }
27044
27045 6075 void getitem(int32_t id, bool nosound, bool doRunPassive)
27046 {
27047
1/2
✓ Branch 0 taken 6075 times.
✗ Branch 1 not taken.
6075 if(id<0)
27048 {
27049 return;
27050 }
27051
27052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6075 times.
6075 if (replay_is_active())
27053
1/2
✓ Branch 0 taken 6075 times.
✗ Branch 1 not taken.
6075 replay_step_comment(fmt::format("getitem {}", item_string[id]));
27054
27055
2/2
✓ Branch 0 taken 6072 times.
✓ Branch 1 taken 3 times.
6075 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
27056 {
27057 3 int32_t nextitem = -1;
27058 3 do
27059 {
27060 3 nextitem = -1;
27061
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
27062 // Item upgrade routine.
27063 {
27064
27065 for(int32_t i=0; i<MAXITEMS; i++)
27066 {
27067 // Find the item which is as close to this item's fam_type as possible.
27068 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
27069 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27070 {
27071 nextitem = i;
27072 }
27073 }
27074
27075 if(nextitem>-1)
27076 {
27077 id = nextitem;
27078 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27079 break; //no looping
27080 }
27081 }
27082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 } while(nextitem > -1);
27083 3 }
27084
27085 6075 itemdata const& idat = itemsbuf[id&0xFF];
27086 // if(idat.family!=0xFF) //1.92 compat... that already should be changed to 'itype_misc'? Blehg, hate this! -Em
27087 {
27088
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 5512 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 528 times.
6075 if(idat.flags & ITEM_GAMEDATA && idat.family != itype_triforcepiece)
27089 {
27090 // Fix boomerang sounds.
27091 528 int32_t itemid = current_item_id(idat.family);
27092
27093
4/6
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 235 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_nayruslove
27094
3/6
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 288 times.
✗ Branch 5 not taken.
288 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
27095 293 && sfx_allocated(itemsbuf[itemid].usesound)
27096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 && idat.usesound != itemsbuf[itemid].usesound)
27097 {
27098 stop_sfx(itemsbuf[itemid].usesound);
27099 cont_sfx(idat.usesound);
27100 }
27101
27102 528 int32_t curitm = current_item_id(idat.family);
27103
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
528 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
27104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
528 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
27105 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
27106 {
27107 528 game->set_item(id,true);
27108 528 passiveitem_script(id, doRunPassive);
27109 528 }
27110
27111
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 382 times.
528 if(!(idat.flags & ITEM_KEEPOLD))
27112 {
27113
3/4
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 349 times.
382 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
27114 {
27115 33 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
27116 33 }
27117 382 }
27118
27119 // NES consistency: replace all flying boomerangs with the current boomerang.
27120
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 16 times.
528 if(idat.family==itype_brang)
27121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for(int32_t i=0; i<Lwpns.Count(); i++)
27122 {
27123 weapon *w = ((weapon*)Lwpns.spr(i));
27124
27125 if(w->id==wBrang)
27126 {
27127 w->LOADGFX(idat.wpn);
27128 }
27129 16 }
27130 528 }
27131
27132
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 5119 times.
6075 if(idat.count!=-1)
27133 {
27134
2/2
✓ Branch 0 taken 4982 times.
✓ Branch 1 taken 137 times.
5119 if(idat.setmax)
27135 {
27136 // Bomb bags are a special case; they may be set not to increase super bombs
27137
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 134 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
137 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
27138 {
27139 int32_t max = game->get_maxbombs();
27140
27141 if(max<idat.max) max=idat.max;
27142
27143 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
27144 }
27145 else
27146 {
27147 137 int32_t max = game->get_maxcounter(idat.count);
27148
27149
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 114 times.
137 if(max<idat.max) max=idat.max;
27150
27151
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 39 times.
137 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
27152 }
27153 137 }
27154
27155 // Amount is an uint16_t, but the range is -9999 to 16383
27156 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
27157
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4938 times.
5119 if(idat.amount&0x3FFF)
27158 {
27159
2/2
✓ Branch 0 taken 3380 times.
✓ Branch 1 taken 1558 times.
4938 if(idat.amount&0x8000)
27160 6760 game->set_dcounter(
27161
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3379 times.
3380 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27162 else
27163 {
27164
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1558 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1558 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
27165 game->set_counter(0, idat.count);
27166 else
27167 // This is too confusing to try and change...
27168
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1558 times.
✓ Branch 2 taken 686 times.
✓ Branch 3 taken 872 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 686 times.
1558 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
27169 }
27170 4938 }
27171 5119 }
27172 }
27173
27174
3/4
✓ Branch 0 taken 6075 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 5962 times.
6075 if(idat.playsound&&!nosound)
27175 {
27176 5962 sfx(idat.playsound);
27177 5962 }
27178
27179 //add lower-level items
27180
2/2
✓ Branch 0 taken 6054 times.
✓ Branch 1 taken 21 times.
6075 if(idat.flags&ITEM_GAINOLD)
27181 {
27182
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 21 times.
38 for(int32_t i=idat.fam_type-1; i>0; i--)
27183 {
27184 17 int32_t potid = getItemID(itemsbuf, idat.family, i);
27185
27186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(potid != -1)
27187 {
27188 17 game->set_item(potid, true);
27189 17 }
27190 17 }
27191 21 }
27192
27193
10/14
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 237 times.
✓ Branch 6 taken 39 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 33 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 26 times.
✓ Branch 11 taken 195 times.
✓ Branch 12 taken 23 times.
✗ Branch 13 not taken.
6075 switch(idat.family)
27194 {
27195 case itype_itmbundle:
27196 {
27197 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27198 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27199 bool pscript = (idat.flags & ITEM_FLAG1);
27200 for(auto q = 0; q < 10; ++q)
27201 {
27202 if(unsigned(ids[q]) >= MAXITEMS) continue;
27203 if(pscript)
27204 collectitem_script(ids[q]);
27205 getitem(ids[q], true, true);
27206 }
27207 }
27208 break;
27209
27210 case itype_progressive_itm:
27211 {
27212 int32_t newid = get_progressive_item(idat);
27213 if(newid > -1)
27214 getitem(newid, nosound, true);
27215 }
27216 break;
27217
27218 case itype_bottlefill:
27219 {
27220 if(idat.misc1)
27221 {
27222 game->fillBottle(idat.misc1);
27223 }
27224 }
27225 break;
27226
27227 case itype_clock:
27228 {
27229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 237 times.
237 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27230 break;
27231
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
237 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
27232 break;
27233 237 setClock(watch=true);
27234
27235
2/2
✓ Branch 0 taken 121344 times.
✓ Branch 1 taken 237 times.
121581 for(int32_t i=0; i<eMAXGUYS; i++)
27236 121344 clock_zoras[i]=0;
27237
27238 237 clockclk=itemsbuf[id&0xFF].misc1;
27239 237 sfx(idat.usesound);
27240 }
27241 237 break;
27242
27243 case itype_lkey:
27244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
27245 39 break;
27246
27247 case itype_ring:
27248 case itype_magicring:
27249
5/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
12 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27250 {
27251 12 ringcolor(false);
27252 12 }
27253 12 break;
27254
27255 case itype_whispring:
27256 {
27257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(idat.flags & ITEM_FLAG1)
27258 {
27259
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
27260
27261
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
27262 2 }
27263
27264
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(idat.power==0)
27265 {
27266 1 setSwordClk(0);
27267 1 setItemClk(0);
27268 1 }
27269
27270 2 break;
27271 }
27272
27273
27274 case itype_map:
27275 33 game->lvlitems[dlevel]|=liMAP;
27276 33 break;
27277
27278 case itype_compass:
27279 28 game->lvlitems[dlevel]|=liCOMPASS;
27280 28 break;
27281
27282 case itype_bosskey:
27283 26 game->lvlitems[dlevel]|=liBOSSKEY;
27284 26 break;
27285
27286 case itype_fairy:
27287
27288
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 71 times.
195 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
27289
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
195 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
27290 195 break;
27291
27292 case itype_heartpiece:
27293 23 game->change_HCpieces(1);
27294
27295
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(game->get_HCpieces()<game->get_hcp_per_hc())
27296 18 break;
27297
27298 5 game->set_HCpieces(0);
27299
27300 5 getitem(heart_container_id());
27301 5 break;
27302
27303 case itype_killem:
27304 {
27305 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27306 break;
27307 kill_em_all();
27308 sfx(idat.usesound);
27309 }
27310 break;
27311 }
27312
27313 6075 flushItemCache();
27314 6075 update_subscreens();
27315 6075 load_Sitems(&QMisc);
27316 6075 verifyBothWeapons();
27317 6075 }
27318
27319 void takeitem(int32_t id)
27320 {
27321 game->set_item(id, false);
27322 itemdata const& idat = itemsbuf[id];
27323
27324 /* Lower the counters! */
27325 if(idat.count!=-1)
27326 {
27327 if(idat.setmax)
27328 {
27329 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
27330 }
27331
27332 if(idat.amount&0x3FFF)
27333 {
27334 if(idat.amount&0x8000)
27335 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27336 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27337 }
27338 }
27339
27340 switch(itemsbuf[id&0xFF].family)
27341 {
27342 // NES consistency: replace all flying boomerangs with the current boomerang.
27343 case itype_brang:
27344 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
27345 {
27346 weapon *w = ((weapon*)Lwpns.spr(i));
27347
27348 if(w->id==wBrang)
27349 {
27350 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
27351 }
27352 }
27353
27354 break;
27355
27356 case itype_itmbundle:
27357 {
27358 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27359 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27360 for(auto q = 0; q < 10; ++q)
27361 {
27362 if(unsigned(ids[q]) >= MAXITEMS) continue;
27363 takeitem(ids[q]);
27364 }
27365 }
27366 break;
27367
27368 case itype_progressive_itm:
27369 {
27370 int32_t newid = get_progressive_item(idat, true);
27371 if(newid > -1)
27372 takeitem(newid);
27373 }
27374 break;
27375
27376 case itype_heartpiece:
27377 if(game->get_maxlife()>game->get_hp_per_heart())
27378 {
27379 if(game->get_HCpieces()==0)
27380 {
27381 game->set_HCpieces(game->get_hcp_per_hc());
27382 takeitem(iHeartC);
27383 }
27384
27385 game->change_HCpieces(-1);
27386 }
27387 break;
27388
27389 case itype_map:
27390 game->lvlitems[dlevel]&=~liMAP;
27391 break;
27392
27393 case itype_compass:
27394 game->lvlitems[dlevel]&=~liCOMPASS;
27395 break;
27396
27397 case itype_bosskey:
27398 game->lvlitems[dlevel]&=~liBOSSKEY;
27399 break;
27400
27401 case itype_lkey:
27402 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
27403 break;
27404
27405 case itype_ring:
27406 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27407 {
27408 ringcolor(false);
27409 }
27410 break;
27411 }
27412 }
27413
27414 // Attempt to pick up an item. (-1 = check items touching Hero.)
27415 3625907 void HeroClass::checkitems(int32_t index)
27416 {
27417 3625907 int32_t tmp=currscr>=128?1:0;
27418
27419
2/2
✓ Branch 0 taken 902 times.
✓ Branch 1 taken 3625005 times.
3625907 if(index==-1)
27420 {
27421
2/2
✓ Branch 0 taken 879418 times.
✓ Branch 1 taken 3625005 times.
4504423 for(auto ind = items.Count()-1; ind >= 0; --ind)
27422 {
27423 879418 item* itm = (item*)items.spr(ind);
27424
2/2
✓ Branch 0 taken 879406 times.
✓ Branch 1 taken 12 times.
879418 if(itm->get_forcegrab())
27425 {
27426 12 checkitems(ind);
27427 12 }
27428 879418 }
27429
2/2
✓ Branch 0 taken 504858 times.
✓ Branch 1 taken 3120147 times.
3625005 if(diagonalMovement)
27430 {
27431 504858 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
27432 504858 }
27433 3120147 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
27434 3625005 }
27435
27436
2/2
✓ Branch 0 taken 31530 times.
✓ Branch 1 taken 3594377 times.
3625907 if(index==-1)
27437 3594377 return;
27438
27439 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
27440 // return;
27441 31530 item* ptr = (item*)items.spr(index);
27442 31530 int32_t pickup = ptr->pickup;
27443 31530 int8_t exstate = ptr->pickupexstate;
27444 31530 int32_t PriceIndex = ptr->PriceIndex;
27445 31530 int32_t id2 = ptr->id;
27446 31530 int32_t holdid = ptr->id;
27447 31530 int32_t pstr = ptr->pstring;
27448 31530 int32_t pstr_flags = ptr->pickup_string_flags;
27449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31530 times.
31530 if(ptr->fallclk > 0) return; //Don't pick up a falling item
27450
27451
1/2
✓ Branch 0 taken 31530 times.
✗ Branch 1 not taken.
31530 if(itemsbuf[id2].family == itype_progressive_itm)
27452 {
27453 int32_t newid = get_progressive_item(itemsbuf[id2]);
27454 if(newid > -1)
27455 {
27456 id2 = newid;
27457 holdid = newid;
27458 pstr = itemsbuf[newid].pstring;
27459 pstr_flags = itemsbuf[newid].pickup_string_flags;
27460 }
27461 }
27462
27463
2/2
✓ Branch 0 taken 30808 times.
✓ Branch 1 taken 722 times.
31530 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
27464
27465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31530 times.
31530 if(bottledummy) //Dummy bullshit!
27466 {
27467 if(!game->canFillBottle())
27468 return;
27469 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27470 {
27471 if(!current_item_power(itype_wallet))
27472 {
27473 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27474 int32_t tmpprice = -abs(prices[PriceIndex]);
27475 //game->change_drupy(-abs(prices[priceindex]));
27476 int32_t total = game->get_drupy()-tmpprice;
27477 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27478 game->set_drupy(game->get_drupy()-total);
27479 }
27480 else //infinite wallet
27481 {
27482 game->change_drupy(0);
27483 }
27484 }
27485 boughtsomething=true;
27486 //make the other shop items untouchable after
27487 //you buy something
27488 int32_t count = 0;
27489
27490 for(int32_t i=0; i<3; i++)
27491 {
27492 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
27493 {
27494 ++count;
27495 }
27496 }
27497
27498 for(int32_t i=0; i<items.Count(); i++)
27499 {
27500 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27501 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27502 }
27503
27504 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
27505 id2 = find_bottle_for_slot(slot);
27506 ptr->id = id2;
27507 pstr = 0;
27508 pickup |= ipHOLDUP;
27509 }
27510 else
27511 {
27512 31530 std::vector<int32_t> &ev = FFCore.eventData;
27513 31530 ev.clear();
27514 31530 ev.push_back(id2*10000);
27515 31530 ev.push_back(pickup*10000);
27516 31530 ev.push_back(pstr*10000);
27517 31530 ev.push_back(pstr_flags*10000);
27518 31530 ev.push_back(0);
27519 31530 ev.push_back(ptr->getUID());
27520 31530 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
27521 31530 ev.push_back(0);
27522
27523 31530 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
27524 31530 bool nullify = ev[4] != 0;
27525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31530 times.
31530 if(nullify) return;
27526 31530 id2 = ev[0]/10000;
27527 31530 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
27528 31530 pstr = ev[2] / 10000;
27529 31530 pstr_flags = ev[3] / 10000;
27530
27531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31530 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31530 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
27532 return; //No picking these up unless you have a bottle to fill!
27533
27534
5/6
✓ Branch 0 taken 29890 times.
✓ Branch 1 taken 1640 times.
✓ Branch 2 taken 26344 times.
✓ Branch 3 taken 3546 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26344 times.
31530 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
27535
2/2
✓ Branch 0 taken 26282 times.
✓ Branch 1 taken 62 times.
26344 if(ptr->id!=iFairyMoving)
27536 // wait for it to stop flashing, doesn't check for other items yet
27537 26282 return;
27538
27539
2/2
✓ Branch 0 taken 5233 times.
✓ Branch 1 taken 15 times.
5248 if(pickup&ipENEMY) // item was being carried by enemy
27540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if(more_carried_items()<=1) // 1 includes this own item.
27541 15 hasitem &= ~2;
27542
27543
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 4993 times.
5248 if(pickup&ipDUMMY) // dummy item (usually a rupee)
27544 {
27545
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 24 times.
255 if(pickup&ipMONEY)
27546 24 dospecialmoney(index);
27547
27548 255 return;
27549 }
27550
27551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4993 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4993 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
27552 return;
27553
27554 4993 int32_t nextitem = -1;
27555 4993 do
27556 {
27557 4993 nextitem = -1;
27558
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4980 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 9 times.
4993 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
27559 // Item upgrade routine.
27560 {
27561
27562
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
27563 {
27564 // Find the item which is as close to this item's fam_type as possible.
27565
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9 times.
2304 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
27566
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
20 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27567 {
27568 9 nextitem = i;
27569 9 }
27570 2304 }
27571
27572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(nextitem>-1)
27573 {
27574 9 id2 = nextitem;
27575
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
27576 {
27577 pstr = itemsbuf[id2].pstring;
27578 pstr_flags = itemsbuf[id2].pickup_string_flags;
27579 }
27580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27581 9 break; //no looping
27582 }
27583 }
27584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4984 times.
4984 } while(nextitem > -1);
27585
27586
2/2
✓ Branch 0 taken 4271 times.
✓ Branch 1 taken 722 times.
4993 if(pickup&ipCHECK) // check restrictions
27587
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 106 times.
722 switch(tmpscr[tmp].room)
27588 {
27589 case rSP_ITEM: // special item
27590
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 1 times.
54 if(!canget(id2)) // These ones always need the Hearts Required check
27591 1 return;
27592
27593 53 break;
27594
27595 case rP_SHOP: // potion shop
27596
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 13 times.
106 if(msg_active)
27597 93 return;
27598 [[fallthrough]];
27599 case rSHOP: // shop
27600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27601 {
27602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(!current_item_power(itype_wallet))
27603 {
27604
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 46 times.
575 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27605 46 int32_t tmpprice = -abs(prices[PriceIndex]);
27606 //game->change_drupy(-abs(prices[priceindex]));
27607 46 int32_t total = game->get_drupy()-tmpprice;
27608 46 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27609 46 game->set_drupy(game->get_drupy()-total);
27610 46 }
27611 else //infinite wallet
27612 {
27613 game->change_drupy(0);
27614 }
27615 46 }
27616 46 boughtsomething=true;
27617 //make the other shop items untouchable after
27618 //you buy something
27619 46 int32_t count = 0;
27620
27621
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 46 times.
184 for(int32_t i=0; i<3; i++)
27622 {
27623
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 129 times.
138 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
27624 {
27625 129 ++count;
27626 129 }
27627 138 }
27628
27629
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 46 times.
221 for(int32_t i=0; i<items.Count(); i++)
27630 {
27631
4/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 83 times.
175 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27632 83 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27633 175 }
27634
27635 46 break;
27636 99 }
27637
27638
2/2
✓ Branch 0 taken 455 times.
✓ Branch 1 taken 3915 times.
4370 if(pickup&ipONETIME) // set mITEM for one-time-only items
27639 {
27640 455 setmapflag(mITEM);
27641
27642 //Okay so having old source files is a godsend. You wanna know why?
27643 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
27644 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
27645 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
27646 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
27647 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
27648
27649 /*
27650 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
27651 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
27652
27653 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
27654 // What is etc?! We need to check for every valid state here. ~Gleeok
27655 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
27656 {
27657 // Most older quests need one-time-pickups to not remove special items, etc.
27658 if(tmpscr->room==rGRUMBLE)
27659 {
27660 setmapflag(mSPECIALITEM);
27661 }
27662 }
27663 */
27664 455 }
27665
2/2
✓ Branch 0 taken 3724 times.
✓ Branch 1 taken 191 times.
3915 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
27666
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 39 times.
191 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27667
27668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4370 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4370 if(exstate > -1 && exstate < 32)
27669 {
27670 setxmapflag(1<<exstate);
27671 }
27672
27673
1/2
✓ Branch 0 taken 4370 times.
✗ Branch 1 not taken.
4370 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
27674 {
27675 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
27676 hidden_entrance(0, true, false, -5);
27677 }
27678
27679 4370 collectitem_script(id2);
27680 4370 getitem(id2, false, true);
27681 }
27682
27683
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 3987 times.
4370 if(pickup&ipHOLDUP)
27684 {
27685 383 attackclk=0;
27686 383 reset_swordcharge();
27687
27688
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 379 times.
383 if(action!=swimming && !IsSideSwim())
27689 379 reset_hookshot();
27690
27691
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 108 times.
383 if(msg_onscreen)
27692 {
27693 108 dismissmsg();
27694 108 }
27695
27696 383 clear_bitmap(pricesdisplaybuf);
27697
27698
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
383 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
27699 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
27700 {
27701 383 fadeclk=66;
27702 383 }
27703
27704
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 381 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
383 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
27705 {
27706 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
27707
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 377 times.
381 if(action==swimming)
27708 {
27709 4 action=waterhold1; FFCore.setHeroAction(waterhold1);
27710 4 }
27711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 else if(IsSideSwim())
27712 {
27713 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
27714 }
27715 else
27716 {
27717 377 action=landhold1; FFCore.setHeroAction(landhold1);
27718 }
27719
27720
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 118 times.
381 if(ptr->twohand)
27721 {
27722
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 117 times.
118 if(action==waterhold1)
27723 {
27724 1 action=waterhold2; FFCore.setHeroAction(waterhold2);
27725 1 }
27726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 else if(action==sidewaterhold1)
27727 {
27728 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
27729 }
27730 else
27731 {
27732 117 action=landhold2; FFCore.setHeroAction(landhold2);
27733 }
27734 118 }
27735
27736 381 holdclk=130;
27737
27738 //restart music
27739
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 77 times.
381 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
27740 77 music_stop();
27741
27742 381 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
27743 381 freeze_guys=true;
27744 //show the info string
27745
27746
27747 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
27748
27749 381 int32_t shop_pstr = 0;
27750
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 57 times.
381 if (PriceIndex > -1)
27751 {
27752
2/3
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
57 switch(tmpscr[tmp].room)
27753 {
27754 case rSHOP:
27755 33 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
27756 33 break;
27757 case rBOTTLESHOP:
27758 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
27759 break;
27760 }
27761 57 }
27762
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 381 times.
381 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27763 {
27764 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
27765 {
27766 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27767 }
27768 else pstr = 0;
27769 if(shop_pstr)
27770 {
27771 donewmsg(shop_pstr);
27772 enqueued_str = pstr;
27773 }
27774 else if(pstr)
27775 {
27776 donewmsg(pstr);
27777 }
27778 }
27779
27780 381 }
27781
27782
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 348 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
383 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
27783 {
27784 348 sfx(tmpscr[0].holdupsfx);
27785 348 }
27786
27787 383 ptr->set_forcegrab(false);
27788 383 items.del(index);
27789
27790
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 383 times.
496 for(int32_t i=0; i<Lwpns.Count(); i++)
27791 {
27792 113 weapon *w = (weapon*)Lwpns.spr(i);
27793
27794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(w->dragging==index)
27795 {
27796 w->dragging=-1;
27797 }
27798
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 else if(w->dragging>index)
27799 {
27800 w->dragging-=1;
27801 }
27802 113 }
27803
27804 // clear up shop stuff
27805
4/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 139 times.
✓ Branch 3 taken 56 times.
383 if((isdungeon()==0)&&(index!=0))
27806 {
27807
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 42 times.
56 if(boughtsomething)
27808 {
27809 42 fadeclk=66;
27810
27811
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
27812 {
27813 42 items.del(0);
27814
27815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
27816 {
27817 weapon *w = (weapon*)Lwpns.spr(i);
27818
27819 if(w->dragging==0)
27820 {
27821 w->dragging=-1;
27822 }
27823 else if(w->dragging>0)
27824 {
27825 w->dragging-=1;
27826 }
27827 }
27828 42 }
27829 42 }
27830
27831
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(msg_onscreen)
27832 {
27833 dismissmsg();
27834 }
27835
27836 56 clear_bitmap(pricesdisplaybuf);
27837 56 set_clip_state(pricesdisplaybuf, 1);
27838 56 }
27839
27840 // items.del(index);
27841 383 }
27842 else
27843 {
27844 3987 ptr->set_forcegrab(false);
27845 3987 items.del(index);
27846
27847
2/2
✓ Branch 0 taken 3698 times.
✓ Branch 1 taken 3987 times.
7685 for(int32_t i=0; i<Lwpns.Count(); i++)
27848 {
27849 3698 weapon *w = (weapon*)Lwpns.spr(i);
27850
27851
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 3665 times.
3698 if(w->dragging==index)
27852 {
27853 33 w->dragging=-1;
27854 33 }
27855
1/2
✓ Branch 0 taken 3665 times.
✗ Branch 1 not taken.
3665 else if(w->dragging>index)
27856 {
27857 w->dragging-=1;
27858 }
27859 3698 }
27860
27861
2/2
✓ Branch 0 taken 3986 times.
✓ Branch 1 taken 1 times.
3987 if(msg_onscreen)
27862 {
27863 1 dismissmsg();
27864 1 }
27865
27866 //general item pickup message
27867 //show the info string
27868 //non-held
27869 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
27870
3/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 3901 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3987 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
27871
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3986 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3986 times.
3987 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27872 {
27873
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
27874 {
27875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27876 1 }
27877 else pstr = 0;
27878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
27879 {
27880 donewmsg(shop_pstr);
27881 enqueued_str = pstr;
27882 }
27883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
27884 {
27885 1 donewmsg(pstr);
27886 1 }
27887 1 }
27888
27889
27890 3987 clear_bitmap(pricesdisplaybuf);
27891 3987 set_clip_state(pricesdisplaybuf, 1);
27892 }
27893
27894
2/2
✓ Branch 0 taken 4330 times.
✓ Branch 1 taken 40 times.
4370 if(itemsbuf[id2].family==itype_triforcepiece)
27895 {
27896
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 5 times.
40 if(itemsbuf[id2].misc2>0) //Small TF Piece
27897 {
27898 35 getTriforce(id2);
27899 35 }
27900 else
27901 {
27902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (ptr->linked_parent == eeGANON) game->lvlitems[dlevel]|=liBOSS;
27903 5 getBigTri(id2);
27904 }
27905 40 }
27906 3625907 }
27907
27908 126 void HeroClass::StartRefill(int32_t refillWhat)
27909 {
27910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!refilling)
27911 {
27912 126 refillclk=21;
27913 126 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27914 126 sfx(WAV_REFILL,128,true);
27915 126 refilling=refillWhat;
27916
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 6 times.
126 if(FFCore.quest_format[vZelda] < 0x255)
27917 {
27918 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
27919 //I attempted to change this check to a quest rule, but here's the issue: this affects
27920 //triforces and potions as well, not just fairy flags. This means that having a compat rule
27921 //would result in a rule that is checked by default for every tileset or quest made before
27922 //2.55, one in a place most people won't check. That means that if they were to go to use
27923 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
27924 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
27925 //"go through the compat rules and turn them all off", so this remains a version check instead
27926 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
27927 120 Start250Refill(refillWhat);
27928 120 }
27929 else //use 2.55+ behavior
27930 {
27931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(refill_why>=0) // Item index
27932 {
27933 if(itemsbuf[refill_why].family==itype_potion)
27934 {
27935 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27936 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27937 }
27938 else if(itemsbuf[refill_why].family==itype_triforcepiece)
27939 {
27940 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27941 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27942 }
27943 }
27944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(refill_why==REFILL_FAIRY)
27945 {
27946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
27947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
27948 6 }
27949 }
27950 126 }
27951 126 }
27952
27953 120 void HeroClass::Start250Refill(int32_t refillWhat)
27954 {
27955
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!refilling)
27956 {
27957 refillclk=21;
27958 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27959 sfx(WAV_REFILL,128,true);
27960 refilling=refillWhat;
27961
27962 if(refill_why>=0) // Item index
27963 {
27964 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
27965 {
27966 swordclk=0;
27967 verifyAWpn();
27968 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27969 }
27970
27971 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
27972 {
27973 swordclk=0;
27974 verifyAWpn();
27975 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27976 }
27977 }
27978 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
27979 {
27980 swordclk=0;
27981 verifyAWpn();
27982 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27983 }
27984 }
27985 120 }
27986
27987 132122 bool HeroClass::refill()
27988 {
27989
4/4
✓ Branch 0 taken 13204 times.
✓ Branch 1 taken 118918 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 12568 times.
132122 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
27990 {
27991 119554 return false;
27992 }
27993
27994 12568 ++refillclk;
27995 12568 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
27996 12568 int32_t refill_heart_stop=game->get_maxlife();
27997 12568 int32_t refill_magic_stop=game->get_maxmagic();
27998
27999
4/4
✓ Branch 0 taken 6697 times.
✓ Branch 1 taken 5871 times.
✓ Branch 2 taken 2243 times.
✓ Branch 3 taken 4454 times.
12568 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
28000 {
28001
2/6
✓ Branch 0 taken 4454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4454 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4454 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
28002
2/6
✓ Branch 0 taken 4454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4454 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4454 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
28003 4454 }
28004
28005
2/2
✓ Branch 0 taken 11536 times.
✓ Branch 1 taken 1032 times.
12568 if(refillclk%speed == 0)
28006 {
28007 // game->life&=0xFFC;
28008
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 571 times.
1032 switch(refill_what)
28009 {
28010 case REFILL_LIFE:
28011
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 433 times.
461 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28012
28013
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 390 times.
461 if(game->get_life()>=refill_heart_stop)
28014 {
28015 71 game->set_life(refill_heart_stop);
28016 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28017
2/2
✓ Branch 0 taken 18176 times.
✓ Branch 1 taken 71 times.
18247 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28018 {
28019
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 18105 times.
18176 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28020
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 18104 times.
18105 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28021 18104 stop_sfx(q);
28022 18104 }
28023 71 sfx(QMisc.miscsfx[sfxREFILL]);
28024 71 refilling=REFILL_NONE;
28025 71 return false;
28026 }
28027
28028 390 break;
28029
28030 case REFILL_MAGIC:
28031 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28032
28033 if(game->get_magic()>=refill_magic_stop)
28034 {
28035 game->set_magic(refill_magic_stop);
28036 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28037 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28038 {
28039 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28040 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28041 stop_sfx(q);
28042 }
28043 sfx(QMisc.miscsfx[sfxREFILL]);
28044 refilling=REFILL_NONE;
28045 return false;
28046 }
28047
28048 break;
28049
28050 case REFILL_ALL:
28051
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 524 times.
571 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28052
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 12 times.
571 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28053
28054
4/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 504 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 12 times.
571 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
28055 {
28056 55 game->set_life(refill_heart_stop);
28057 55 game->set_magic(refill_magic_stop);
28058 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28059
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 55 times.
14135 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28060 {
28061
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 14025 times.
14080 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28062
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14007 times.
14025 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28063 14007 stop_sfx(q);
28064 14007 }
28065 55 sfx(QMisc.miscsfx[sfxREFILL]);
28066 55 refilling=REFILL_NONE;
28067 55 return false;
28068 }
28069
28070 516 break;
28071 }
28072 906 }
28073
28074 12442 return true;
28075 132122 }
28076
28077 35 void HeroClass::getTriforce(int32_t id2)
28078 {
28079
28080 PALETTE flash_pal;
28081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
28082
28083
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i=0; i<256; i++)
28084 {
28085
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7168 times.
8960 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
28086 8960 }
28087
28088
28089
28090 //get rid off all sprites but Hero
28091 35 guys.clear();
28092 35 items.clear();
28093 35 Ewpns.clear();
28094 35 Lwpns.clear();
28095 35 Sitems.clear();
28096 35 chainlinks.clear();
28097
28098 //decorations.clear();
28099
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 17 times.
35 if(!COOLSCROLL)
28100 {
28101 17 show_subscreen_items=false;
28102 17 }
28103
28104 35 sfx(itemsbuf[id2].playsound);
28105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
28106
28107 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
28108
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
28109 {
28110 uint8_t playwav = itemsbuf[id2].misc3;
28111 //zprint2("playwav is: %d\n", playwav);
28112 sfx(playwav);
28113
28114 }
28115
28116 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
28117 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
28118 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
28119 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
28120 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
28121 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
28122 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
28123
28124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
28125 {
28126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(itemsbuf[id2].misc1)
28127 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
28128 else
28129 35 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
28130 35 }
28131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28132 {
28133 35 game->lvlitems[dlevel]|=liTRIFORCE;
28134 35 }
28135
28136 35 int32_t f=0;
28137 35 int32_t x2=0;
28138 35 int32_t curtain_x=0;
28139 35 int32_t c=0;
28140 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
28141 {
28142 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
28143 {
28144 //clear the item script stack for a new script
28145 ri = &(itemCollectScriptData[id2]);
28146 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
28147 ri->Clear();
28148 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
28149 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
28150 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
28151 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
28152 {
28153 item_collect_doscript[id2] = 1;
28154 itemscriptInitialised[id2] = 0;
28155 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
28156 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28157 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
28158 }
28159 else if (!id2 && !item_collect_doscript[id2]) //item 0
28160 {
28161 item_collect_doscript[id2] = 1;
28162 itemscriptInitialised[id2] = 0;
28163 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
28164 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28165 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
28166 }
28167 }
28168 }
28169 */
28170 35 do
28171 {
28172
28173
28174
1/2
✓ Branch 0 taken 18981 times.
✗ Branch 1 not taken.
18981 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
28175 {
28176 if ( itemsbuf[id2].script )
28177 {
28178 if ( !item_doscript[id2] )
28179 {
28180 ri = &(itemScriptData[id2]);
28181 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
28182 ri->Clear();
28183 item_doscript[id2] = 1;
28184 itemscriptInitialised[id2] = 0;
28185 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
28186 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
28187 }
28188 else
28189 {
28190 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
28191 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
28192 }
28193 }
28194 }
28195 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
28196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
28197 {
28198 return;
28199 }
28200
2/2
✓ Branch 0 taken 18946 times.
✓ Branch 1 taken 35 times.
18981 if(f==40)
28201 {
28202 35 actiontype oldaction = action;
28203 35 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
28204 35 action=oldaction; // have to reset this flag
28205 35 FFCore.setHeroAction(oldaction);
28206 35 }
28207
28208
28209
4/4
✓ Branch 0 taken 17581 times.
✓ Branch 1 taken 1400 times.
✓ Branch 2 taken 15901 times.
✓ Branch 3 taken 1680 times.
18981 if(f>=40 && f<88)
28210 {
28211
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 1344 times.
1680 if(get_bit(quest_rules,qr_FADE))
28212 {
28213 //int32_t flashbit = ;
28214
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 84 times.
336 if((f&(((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)) ? 6 : 3))==0)
28215 {
28216 84 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
28217 84 refreshpal=true;
28218 84 }
28219
28220
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 84 times.
336 if((f&3)==2)
28221 {
28222 84 loadpalset(0,0);
28223 84 loadpalset(1,1);
28224 84 loadpalset(5,5);
28225
28226
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28227 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
28228 84 }
28229 336 }
28230 else
28231 {
28232
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&((get_bit(quest_rules,qr_EPILEPSY)) ? 10 : 7))==0)
28233 {
28234
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t cs2=2; cs2<5; cs2++)
28235 {
28236
2/2
✓ Branch 0 taken 7560 times.
✓ Branch 1 taken 504 times.
8064 for(int32_t i=1; i<16; i++)
28237 {
28238 7560 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
28239 7560 }
28240 504 }
28241
28242 168 refreshpal=true;
28243 168 }
28244
28245
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
28246 {
28247
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28248 else loadlvlpal(0xB);
28249
28250 168 loadpalset(5,5);
28251 168 }
28252 }
28253 1680 }
28254
28255
28256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28257 {
28258
2/2
✓ Branch 0 taken 18946 times.
✓ Branch 1 taken 35 times.
18981 if(f==refill_frame)
28259 {
28260 35 refill_what=REFILL_ALL;
28261 35 refill_why=id2;
28262 35 StartRefill(REFILL_ALL);
28263 35 refill();
28264 35 }
28265
28266
2/2
✓ Branch 0 taken 16765 times.
✓ Branch 1 taken 2216 times.
18981 if(f==(refill_frame+1))
28267 {
28268
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2181 times.
2216 if(refill())
28269 {
28270 2181 --f;
28271 2181 }
28272 2216 }
28273 18981 }
28274
28275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
28276 {
28277
4/4
✓ Branch 0 taken 9520 times.
✓ Branch 1 taken 9461 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 2800 times.
18981 if(f>=208 && f<288)
28278 {
28279 2800 ++x2;
28280
28281
3/3
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 1120 times.
✓ Branch 2 taken 560 times.
2800 switch(++c)
28282 {
28283 case 5:
28284 560 c=0;
28285 [[fallthrough]];
28286 case 0:
28287 case 2:
28288 case 3:
28289 1680 ++x2;
28290 1680 break;
28291 }
28292 2800 }
28293
28294 18981 do_dcounters();
28295
28296
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 12261 times.
18981 if(f<288)
28297 {
28298 12261 curtain_x=x2&0xF8;
28299 12261 draw_screen_clip_rect_x1=curtain_x;
28300 12261 draw_screen_clip_rect_x2=255-curtain_x;
28301 12261 draw_screen_clip_rect_y1=0;
28302 12261 draw_screen_clip_rect_y2=223;
28303 //draw_screen(tmpscr);
28304 12261 }
28305 18981 }
28306
28307 18981 draw_screen(tmpscr);
28308 //this causes bugs
28309 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
28310 //so this is not necessary -DD
28311 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
28312
28313 //Run Triforce Script
28314 18981 advanceframe(true);
28315 18981 ++f;
28316
2/2
✓ Branch 0 taken 18946 times.
✓ Branch 1 taken 35 times.
37962 }
28317 while
28318 (
28319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
28320
4/6
✓ Branch 0 taken 2555 times.
✓ Branch 1 taken 16426 times.
✓ Branch 2 taken 2555 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2555 times.
18981 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
28321
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2555 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2555 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2409 times.
✓ Branch 7 taken 146 times.
5110 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
28322 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
28323 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
28324 // value doesn't matter.
28325
2/4
✓ Branch 0 taken 2409 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2555 times.
2555 || (replay_is_active() && f < 480) )
28326 ); // 800 may not be just right, but it works
28327
28328 35 action=none; FFCore.setHeroAction(none);
28329 35 holdclk=0;
28330 35 draw_screen_clip_rect_x1=0;
28331 35 draw_screen_clip_rect_x2=255;
28332 35 draw_screen_clip_rect_y1=0;
28333 35 draw_screen_clip_rect_y2=223;
28334 35 show_subscreen_items=true;
28335
28336 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
28337 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
28338
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
35 if(itemsbuf[id2].flags & ITEM_FLAG1 && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
28339 {
28340 36 sdir=dir;
28341 36 dowarp(1,0); //side warp
28342 36 }
28343 else
28344 {
28345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
28346 }
28347 35 }
28348
28349 1221 void red_shift()
28350 {
28351 1221 int32_t tnum=176;
28352
28353 // set up the new palette
28354
2/2
✓ Branch 0 taken 39072 times.
✓ Branch 1 taken 1221 times.
40293 for(int32_t i=CSET(2); i < CSET(4); i++)
28355 {
28356 39072 int32_t r = (i-CSET(2)) << 1;
28357 39072 RAMpal[i+tnum].r = r;
28358 39072 RAMpal[i+tnum].g = r >> 3;
28359 39072 RAMpal[i+tnum].b = r >> 4;
28360 39072 }
28361
28362 // color scale the game screen
28363
2/2
✓ Branch 0 taken 205128 times.
✓ Branch 1 taken 1221 times.
206349 for(int32_t y=0; y<168; y++)
28364 {
28365
2/2
✓ Branch 0 taken 52512768 times.
✓ Branch 1 taken 205128 times.
52717896 for(int32_t x=0; x<256; x++)
28366 {
28367 52512768 int32_t c = framebuf->line[y+playing_field_offset][x];
28368
2/2
✓ Branch 0 taken 46991727 times.
✓ Branch 1 taken 5521041 times.
52512768 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28369
1/2
✓ Branch 0 taken 52512768 times.
✗ Branch 1 not taken.
52512768 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
28370 52512768 }
28371 205128 }
28372
28373 1221 refreshpal = true;
28374 1221 }
28375
28376
28377
28378 void setup_red_screen_old()
28379 {
28380 clear_bitmap(framebuf);
28381 rectfill(scrollbuf, 0, 0, 255, 167, 0);
28382
28383 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
28384
28385 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
28386
28387 putscr(scrollbuf, 0, 0, tmpscr);
28388 putscrdoors(scrollbuf,0,0,tmpscr);
28389 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28390 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
28391
28392 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
28393
28394 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
28395 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
28396 {
28397 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
28398 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
28399 }
28400
28401 if(!(msg_bg_display_buf->clip))
28402 {
28403 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28404 }
28405
28406 if(!(msg_portrait_display_buf->clip))
28407 {
28408 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28409 }
28410
28411 if(!(msg_txt_display_buf->clip))
28412 {
28413 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28414 }
28415
28416 if(!(pricesdisplaybuf->clip))
28417 {
28418 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
28419 }
28420
28421 //red shift
28422 // color scale the game screen
28423 for(int32_t y=0; y<168; y++)
28424 {
28425 for(int32_t x=0; x<256; x++)
28426 {
28427 int32_t c = framebuf->line[y+playing_field_offset][x];
28428 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28429 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
28430 }
28431 }
28432
28433 // Hero->draw(framebuf);
28434 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
28435
28436 clear_bitmap(framebuf);
28437
28438 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
28439 && tmpscr->layermap[3]==0
28440 && tmpscr->layermap[4]==0
28441 && tmpscr->layermap[5]==0
28442 && !overheadcombos(tmpscr)))
28443 {
28444 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
28445
28446 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
28447 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
28448 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
28449 {
28450 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
28451 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
28452 }
28453 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
28454 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
28455
28456 //do an AND masked blit for messages on top of layers
28457 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
28458 {
28459 BITMAP* subbmp = create_bitmap_ex(8,256,168);
28460 clear_bitmap(subbmp);
28461 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
28462 {
28463 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
28464 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
28465 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
28466 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
28467 }
28468 for(int32_t y=0; y<168; y++)
28469 {
28470 for(int32_t x=0; x<256; x++)
28471 {
28472 int32_t c1 = framebuf->line[y+playing_field_offset][x];
28473 int32_t c2 = subbmp->line[y][x];
28474 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
28475
28476 if(c1 && c3)
28477 {
28478 framebuf->line[y+playing_field_offset][x] = c3;
28479 }
28480 else if(c1 && c2)
28481 {
28482 framebuf->line[y+playing_field_offset][x] = c2;
28483 }
28484 }
28485 }
28486 destroy_bitmap(subbmp);
28487 }
28488
28489 //red shift
28490 // color scale the game screen
28491 for(int32_t y=0; y<168; y++)
28492 {
28493 for(int32_t x=0; x<256; x++)
28494 {
28495 int32_t c = framebuf->line[y+playing_field_offset][x];
28496 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28497 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
28498 }
28499 }
28500 }
28501
28502 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
28503
28504 // set up the new palette
28505 for(int32_t i=CSET(2); i < CSET(4); i++)
28506 {
28507 int32_t r = (i-CSET(2)) << 1;
28508 RAMpal[i].r = r;
28509 RAMpal[i].g = r >> 3;
28510 RAMpal[i].b = r >> 4;
28511 }
28512
28513 refreshpal = true;
28514 }
28515
28516
28517
28518 60 void slide_in_color(int32_t color)
28519 {
28520
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 60 times.
360 for(int32_t i=1; i<16; i+=3)
28521 {
28522 300 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
28523 300 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
28524 300 RAMpal[CSET(2)+i] = NESpal(color);
28525 300 }
28526
28527 60 refreshpal=true;
28528 60 }
28529
28530
28531 24 void HeroClass::heroDeathAnimation()
28532 {
28533 24 int32_t f=0;
28534 24 int32_t deathclk=0,deathfrm=0;
28535
28536 24 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
28537
28538 24 kill_sfx(); //call before the onDeath script.
28539
28540 //do
28541 //{
28542
28543 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28544 // FFCore.Waitframe();
28545 //}while(player_doscript);
28546 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28547 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
28548
28549 //Playing=false;
28550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!debug_enabled)
28551 {
28552 24 Paused=false;
28553 24 }
28554
28555 /*
28556 game->set_deaths(zc_min(game->get_deaths()+1,999));
28557 dir=down;
28558 music_stop();
28559
28560 attackclk=hclk=superman=0;
28561 scriptcoldet = 1;
28562
28563 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28564
28565
28566
28567 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28568 quakeclk=wavy=0;
28569
28570 //in original Z1, Hero marker vanishes at death.
28571 //code in subscr.cpp, put_passive_subscr checks the following value.
28572 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28573 //Also, subscreen is static after death in Z1.
28574 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28575 QMisc.colors.hero_dot = 255;
28576 //doesn't work
28577 //scrollbuf is tampered with by draw_screen()
28578 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28579 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28580 clear_bitmap(subscrbmp);
28581 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
28582 QMisc.colors.hero_dot = tmp_hero_dot;
28583 */
28584 24 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28585 24 clear_bitmap(subscrbmp);
28586 //get rid off all sprites but Hero
28587 24 guys.clear();
28588 24 items.clear();
28589 24 Ewpns.clear();
28590 24 Lwpns.clear();
28591 24 Sitems.clear();
28592 24 chainlinks.clear();
28593 24 decorations.clear();
28594 24 Playing = false;
28595
28596
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
28597 24 dir=down;
28598 24 music_stop();
28599
28600 24 attackclk=hclk=superman=0;
28601 24 scriptcoldet = 1;
28602
28603
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24 times.
792 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28604
28605
28606
28607 24 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28608 24 quakeclk=wavy=0;
28609
28610 //in original Z1, Hero marker vanishes at death.
28611 //code in subscr.cpp, put_passive_subscr checks the following value.
28612 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28613 //Also, subscreen is static after death in Z1.
28614 24 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28615 24 QMisc.colors.hero_dot = 255;
28616 //doesn't work
28617 //scrollbuf is tampered with by draw_screen()
28618 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28619
28620 24 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
28621 //Don't forget passive subscreen scripts!
28622
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
28623 {
28624 1 script_drawing_commands.Clear(); //We only want draws from this script
28625
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(DMaps[currdmap].passive_sub_script != 0)
28626 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28627
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
28628 {
28629 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28630 passive_subscreen_waitdraw = false;
28631 }
28632 1 BITMAP* tmp = framebuf;
28633 1 framebuf = subscrbmp; //Hack; force draws to subscrbmp
28634 1 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
28635 1 framebuf = tmp;
28636 1 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
28637 1 }
28638 24 QMisc.colors.hero_dot = tmp_hero_dot;
28639 24 bool clearedit = false;
28640 24 do
28641 {
28642 //if ( player_doscript )
28643 //{
28644 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_WIN, SCRIPT_PLAYER_WIN);
28645 //if ( f ) --f;
28646 // load_control_state(); //goto adv;
28647 //}
28648 //else
28649 //{
28650 // if ( !clearedit )
28651 // {
28652
28653
28654 // clearedit = true;
28655
28656 // }
28657 //}
28658 //else Playing = false;
28659
2/2
✓ Branch 0 taken 5892 times.
✓ Branch 1 taken 2277 times.
8169 if(f<254)
28660 {
28661
2/2
✓ Branch 0 taken 5100 times.
✓ Branch 1 taken 792 times.
5892 if(f<=32)
28662 {
28663 792 hclk=(32-f);
28664 792 }
28665
28666
4/4
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 1476 times.
✓ Branch 2 taken 2668 times.
✓ Branch 3 taken 1748 times.
5892 if(f>=62 && f<138)
28667 {
28668
5/5
✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 92 times.
✓ Branch 4 taken 92 times.
1748 switch((f-62)%20)
28669 {
28670 case 0:
28671 92 dir=right;
28672 92 break;
28673
28674 case 5:
28675 92 dir=up;
28676 92 break;
28677
28678 case 10:
28679 92 dir=left;
28680 92 break;
28681
28682 case 15:
28683 92 dir=down;
28684 92 break;
28685 }
28686
28687 1748 herostep();
28688 1748 }
28689
28690
4/4
✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 4512 times.
✓ Branch 2 taken 1058 times.
✓ Branch 3 taken 322 times.
5892 if(f>=194 && f<208)
28691 {
28692
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 23 times.
322 if(f==194)
28693 {
28694 23 action=dying;
28695 23 FFCore.setHeroAction(dying);
28696 23 }
28697
28698 322 extend = 0;
28699 322 cs = wpnsbuf[spr_death].csets&15;
28700 322 tile = wpnsbuf[spr_death].tile;
28701
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
28702 {
28703 tile += deathfrm;
28704 f = 206;
28705 if(++deathclk >= wpnsbuf[spr_death].speed)
28706 {
28707 deathclk=0;
28708 if(++deathfrm >= wpnsbuf[spr_death].frames)
28709 {
28710 f = 208;
28711 deathfrm = 0;
28712 }
28713 }
28714 }
28715
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 182 times.
322 else if(BSZ)
28716 {
28717 140 tile += (f-194)/3;
28718 140 }
28719
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 52 times.
182 else if(f>=204)
28720 {
28721 52 ++tile;
28722 52 }
28723 322 }
28724
28725
2/2
✓ Branch 0 taken 5869 times.
✓ Branch 1 taken 23 times.
5892 if(f==208)
28726 {
28727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if ( dontdraw < 2 ) { dontdraw = 1; }
28728 23 }
28729
2/2
✓ Branch 0 taken 2844 times.
✓ Branch 1 taken 3048 times.
5892 if(get_bit(quest_rules,qr_FADE))
28730 {
28731
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 924 times.
2844 if(f < 170)
28732 {
28733
2/2
✓ Branch 0 taken 1210 times.
✓ Branch 1 taken 710 times.
1920 if(f<60)
28734 {
28735 710 draw_screen(tmpscr);
28736 //reuse our static subscreen
28737 710 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28738 710 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28739 710 }
28740
28741
2/2
✓ Branch 0 taken 1909 times.
✓ Branch 1 taken 11 times.
1920 if(f==60)
28742 {
28743 11 red_shift();
28744 11 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28745 11 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28746 11 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28747
28748
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t q=0; q<PAL_SIZE; q++)
28749 {
28750 2816 trans_table2.data[0][q] = q;
28751 2816 trans_table2.data[q][q] = q;
28752 2816 }
28753 11 }
28754
28755
3/4
✓ Branch 0 taken 1210 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1210 times.
1920 if(f>=60 && f<=169)
28756 {
28757 1210 draw_screen(tmpscr);
28758 //reuse our static subscreen
28759 1210 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28760 1210 red_shift();
28761
28762 1210 }
28763
28764
3/4
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 1579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 341 times.
1920 if(f>=139 && f<=169)//fade from red to black
28765 {
28766 341 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
28767 341 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28768 341 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28769 341 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28770
28771
2/2
✓ Branch 0 taken 87296 times.
✓ Branch 1 taken 341 times.
87637 for(int32_t q=0; q<PAL_SIZE; q++)
28772 {
28773 87296 trans_table2.data[0][q] = q;
28774 87296 trans_table2.data[q][q] = q;
28775 87296 }
28776
28777 341 refreshpal=true;
28778 341 }
28779 1920 }
28780 else //f>=170
28781 {
28782
2/2
✓ Branch 0 taken 913 times.
✓ Branch 1 taken 11 times.
924 if(f==170)//make Hero grayish
28783 {
28784 11 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
28785
28786
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 11 times.
187 for(int32_t i=CSET(6); i < CSET(7); i++)
28787 {
28788 176 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
28789 176 RAMpal[i] = _RGB(g,g,g);
28790 176 }
28791
28792 11 refreshpal = true;
28793 11 }
28794
28795 //draw only hero. otherwise black layers might cover him.
28796 924 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28797 924 draw(framebuf);
28798 924 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28799 }
28800 2844 }
28801 else //!qr_FADE
28802 {
28803
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==58)
28804 {
28805
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 12 times.
1164 for(int32_t i = 0; i < 96; i++)
28806 1152 tmpscr->cset[i] = 3;
28807
28808
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28809
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28810
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
28811 194 tmpscr2[j].cset[i] = 3;
28812 12 }
28813
28814
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==59)
28815 {
28816
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 12 times.
972 for(int32_t i = 96; i < 176; i++)
28817 960 tmpscr->cset[i] = 3;
28818
28819
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28820
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28821
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
28822 162 tmpscr2[j].cset[i] = 3;
28823 12 }
28824
28825
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==60)
28826 {
28827
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 for(int32_t i=0; i<176; i++)
28828 {
28829 2112 tmpscr->cset[i] = 2;
28830 2112 }
28831
28832
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28833
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28834
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
28835 354 tmpscr2[j].cset[i] = 2;
28836
28837
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
28838 {
28839 60 RAMpal[CSET(2)+i] = NESpal(0x17);
28840 60 RAMpal[CSET(2)+i+1] = NESpal(0x16);
28841 60 RAMpal[CSET(2)+i+2] = NESpal(0x26);
28842 60 }
28843
28844 12 refreshpal=true;
28845 12 }
28846
28847
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==139)
28848 12 slide_in_color(0x06);
28849
28850
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==149)
28851 12 slide_in_color(0x07);
28852
28853
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==159)
28854 12 slide_in_color(0x0F);
28855
28856
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==169)
28857 {
28858 12 slide_in_color(0x0F);
28859 12 slide_in_color(0x0F);
28860 12 }
28861
28862
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==170)
28863 {
28864
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
28865 {
28866 60 RAMpal[CSET(6)+i] = NESpal(0x10);
28867 60 RAMpal[CSET(6)+i+1] = NESpal(0x30);
28868 60 RAMpal[CSET(6)+i+2] = NESpal(0x00);
28869 60 refreshpal = true;
28870 60 }
28871 12 }
28872
28873
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 1020 times.
3048 if(f < 169)
28874 {
28875 2028 draw_screen(tmpscr);
28876 //reuse our static subscreen
28877 2028 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28878 2028 }
28879 else
28880 {
28881 //draw only hero. otherwise black layers might cover him.
28882 1020 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28883 1020 draw(framebuf);
28884 1020 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28885 }
28886 }
28887 5892 }
28888
28889
2/2
✓ Branch 0 taken 2208 times.
✓ Branch 1 taken 69 times.
2277 else if(f<350)//draw 'GAME OVER' text
28890 {
28891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2208 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
28892 {
28893 Quit = qRELOAD;
28894 skipcont = 1;
28895 clear_bitmap(framebuf);
28896 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28897 }
28898
2/4
✓ Branch 0 taken 2208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2208 times.
2208 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
28899 {
28900 Quit = qCONT;
28901 skipcont = 1;
28902 clear_bitmap(framebuf);
28903 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28904 }
28905 else
28906 {
28907 2208 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
28908 2208 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28909 2208 textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
28910 }
28911 2208 }
28912 else
28913 {
28914 69 clear_bitmap(framebuf);
28915 }
28916
28917 //SFX... put them all here
28918
4/4
✓ Branch 0 taken 8099 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 23 times.
8169 switch(f)
28919 {
28920 case 0:
28921 24 sfx(getHurtSFX(),pan(x.getInt()));
28922 24 break;
28923 //Death sound.
28924 case 60:
28925 23 sfx(WAV_SPIRAL);
28926 23 break;
28927 //Message sound.
28928 case 194:
28929 23 sfx(WAV_MSG);
28930 23 break;
28931 }
28932 //adv:
28933 8169 advanceframe(true);
28934 8169 ++f;
28935 //if (!player_doscript ) ++f;
28936
2/2
✓ Branch 0 taken 8145 times.
✓ Branch 1 taken 24 times.
16338 }
28937
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 8146 times.
8169 while(f<353 && !Quit);
28938
28939 24 destroy_bitmap(subscrbmp);
28940 24 action=none; FFCore.setHeroAction(none);
28941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if ( dontdraw < 2 ) { dontdraw=0; }
28942 24 }
28943
28944
28945 5 void HeroClass::ganon_intro()
28946 {
28947 /*
28948 ************************
28949 * GANON INTRO SEQUENCE *
28950 ************************
28951 -25 DOT updates
28952 -24 HERO in
28953 0 TRIFORCE overhead - code begins at this point (f == 0)
28954 47 GANON in
28955 58 LIGHT step
28956 68 LIGHT step
28957 78 LIGHT step
28958 255 TRIFORCE out
28959 256 TRIFORCE in
28960 270 TRIFORCE out
28961 271 GANON out, HERO face up
28962 */
28963 5 loaded_guys=true;
28964 5 loaditem();
28965
28966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(game->lvlitems[dlevel]&liBOSS)
28967 {
28968 return;
28969 }
28970
28971 5 dir=down;
28972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if ( !isSideViewHero() )
28973 {
28974 5 fall = 0; //Fix midair glitch on holding triforce. -Z
28975 5 fakefall = 0;
28976 5 z = 0;
28977 5 fakez = 0;
28978 5 }
28979 5 action=landhold2; FFCore.setHeroAction(landhold2);
28980 5 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
28981 //not good, as this only returns the highest level that Hero possesses. -DD
28982 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
28983
28984
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1205 times.
✓ Branch 2 taken 1205 times.
✓ Branch 3 taken 5 times.
1210 for(int32_t f=0; f<271 && !Quit; f++)
28985 {
28986
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
1205 if(f==47)
28987 {
28988 5 music_stop();
28989 5 stop_sfx(WAV_ROAR);
28990 5 sfx(WAV_GASP);
28991 5 sfx(WAV_GANON);
28992 5 int32_t Id=0;
28993
28994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 for(int32_t i=0; i<eMAXGUYS; i++)
28995 {
28996
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 5 times.
395 if(guysbuf[i].flags2&eneflag_ganon)
28997 {
28998 5 Id=i;
28999 5 break;
29000 }
29001 390 }
29002
29003
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(current_item(itype_ring))
29004 {
29005 4 addenemy(160,96,Id,0);
29006 4 }
29007 else
29008 {
29009 1 addenemy(80,32,Id,0);
29010 }
29011 5 }
29012
29013
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
1205 if(f==48)
29014 {
29015 5 lighting(true,true); // Hmm. -L
29016 5 f += 30;
29017 5 }
29018
29019 //NES Z1, the triforce vanishes for one frame in two cases
29020 //while still showing Hero's two-handed overhead sprite.
29021 //This should be a Quest Rule for NES Accuracy. -Z
29022
4/4
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 1195 times.
1205 if(f==255 || f==270)
29023 {
29024 10 holditem=-1;
29025 10 }
29026
29027
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
1205 if(f==256)
29028 {
29029 5 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
29030 5 }
29031
29032 1205 draw_screen(tmpscr);
29033 1205 advanceframe(true);
29034
29035
1/2
✓ Branch 0 taken 1205 times.
✗ Branch 1 not taken.
1205 if(rSbtn())
29036 {
29037 conveyclk=3;
29038 int32_t tmp_subscr_clk = frame;
29039 dosubscr(&QMisc);
29040 newscr_clk += frame - tmp_subscr_clk;
29041 }
29042
29043 1205 }
29044
29045 5 action=none; FFCore.setHeroAction(none);
29046 5 dir=up;
29047
29048
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
5 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
29049 1 jukebox(MAXMIDIS-1);
29050 else
29051 4 playLevelMusic();
29052
29053 5 currcset=DMaps[currdmap].color;
29054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (get_bit(quest_rules, qr_GANONINTRO) )
29055 {
29056 5 dointro();
29057 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
29058 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
29059 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
29060 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
29061 5 }
29062 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
29063 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
29064 //on a different DMap.
29065 //~ Otherwise, why is it here?! -Z
29066
29067
29068 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
29069 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
29070
29071 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
29072 //Users who use that dmap rule should put ganons room on its own DMap! -Z
29073 5 cont_sfx(WAV_ROAR);
29074 5 }
29075
29076 4 void HeroClass::win_game()
29077 {
29078
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 replay_step_comment("win_game");
29079 4 Playing=Paused=false;
29080 4 action=won; FFCore.setHeroAction(won);
29081 4 Quit=qWON;
29082 4 hclk=0;
29083 4 x = 136;
29084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 y = (isdungeon() && currscr<128) ? 75 : 73;
29085 4 z = fakez = fall = fakefall = spins = 0;
29086 4 dir=left;
29087 4 }
29088
29089 8093 void HeroClass::reset_swordcharge()
29090 {
29091 8093 charging=spins=tapping=0;
29092 8093 }
29093
29094 25137 void HeroClass::reset_hookshot()
29095 {
29096
10/12
✓ Branch 0 taken 23308 times.
✓ Branch 1 taken 1829 times.
✓ Branch 2 taken 23304 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 23260 times.
✓ Branch 5 taken 44 times.
✓ Branch 6 taken 23255 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 23255 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 23255 times.
25137 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
29097 {
29098 23255 action=none; FFCore.setHeroAction(none);
29099 23255 }
29100
29101 25137 hookshot_frozen=false;
29102 25137 hookshot_used=false;
29103 25137 pull_hero=false;
29104 25137 hs_fix=false;
29105 25137 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
29106 25137 switch_hooked = false;
29107
1/2
✓ Branch 0 taken 25137 times.
✗ Branch 1 not taken.
25137 if(switching_object)
29108 switching_object->switch_hooked = false;
29109 25137 switching_object = NULL;
29110 25137 hooked_combopos = -1;
29111 25137 switchhook_cost_item = -1;
29112 25137 hooked_layerbits = 0;
29113
2/2
✓ Branch 0 taken 175959 times.
✓ Branch 1 taken 25137 times.
201096 for(auto q = 0; q < 7; ++q)
29114 175959 hooked_undercombos[q] = -1;
29115 25137 Lwpns.del(Lwpns.idFirst(wHSHandle));
29116 25137 Lwpns.del(Lwpns.idFirst(wHookshot));
29117 25137 chainlinks.clear();
29118
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 22663 times.
25137 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
29119 25137 hs_switcher = false;
29120
29121
2/2
✓ Branch 0 taken 21683 times.
✓ Branch 1 taken 3454 times.
25137 if(index>=0)
29122 {
29123 3454 stop_sfx(itemsbuf[index].usesound);
29124 3454 }
29125
29126 25137 hs_xdist=0;
29127 25137 hs_ydist=0;
29128 25137 }
29129
29130
29131 2804085 bool HeroClass::can_deploy_ladder()
29132 {
29133
2/2
✓ Branch 0 taken 309377 times.
✓ Branch 1 taken 2494708 times.
4397530 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
29134
4/4
✓ Branch 0 taken 901263 times.
✓ Branch 1 taken 1593445 times.
✓ Branch 2 taken 52642 times.
✓ Branch 3 taken 1540803 times.
2494708 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
29135
8/10
✓ Branch 0 taken 732548 times.
✓ Branch 1 taken 2071537 times.
✓ Branch 2 taken 698310 times.
✓ Branch 3 taken 34238 times.
✓ Branch 4 taken 698249 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 698249 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 698249 times.
3502334 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
29136
2/2
✓ Branch 0 taken 677569 times.
✓ Branch 1 taken 20680 times.
698249 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
29137 }
29138
29139 3068310 void HeroClass::reset_ladder()
29140 {
29141 3068310 ladderx=laddery=0;
29142 3068310 }
29143
29144 bool is_conveyor(int32_t type);
29145 int32_t get_conveyor(int32_t x, int32_t y);
29146
29147 3628643 void HeroClass::check_conveyor()
29148 {
29149 3628643 ++newconveyorclk;
29150
1/2
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
3628643 if (newconveyorclk < 0) newconveyorclk = 0;
29151
29152
14/18
✓ Branch 0 taken 3628643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3628643 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3627939 times.
✓ Branch 5 taken 704 times.
✓ Branch 6 taken 3627939 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3627939 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3625827 times.
✓ Branch 11 taken 2112 times.
✓ Branch 12 taken 3625682 times.
✓ Branch 13 taken 145 times.
✓ Branch 14 taken 3622413 times.
✓ Branch 15 taken 3269 times.
✓ Branch 16 taken 3622413 times.
✓ Branch 17 taken 3269 times.
3628643 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
29153 {
29154 6230 is_conveyor_stunned = 0;
29155 6230 return;
29156 }
29157
29158 3622413 WalkflagInfo info;
29159 int32_t xoff,yoff;
29160 3622413 zfix deltax(0), deltay(0);
29161 3622413 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
29162
2/2
✓ Branch 0 taken 2417196 times.
✓ Branch 1 taken 1205217 times.
3622413 if(cmbid < 0)
29163 {
29164
2/2
✓ Branch 0 taken 2416513 times.
✓ Branch 1 taken 683 times.
2417196 if (conveyclk <= 0) is_on_conveyor=false;
29165 2417196 return;
29166 }
29167 1205217 newcombo const* cmb = &combobuf[cmbid];
29168 1205217 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
29169 1205217 bool custom_spd = (cmb->usrflags&cflag2);
29170
3/4
✓ Branch 0 taken 1204389 times.
✓ Branch 1 taken 828 times.
✓ Branch 2 taken 1204389 times.
✗ Branch 3 not taken.
1205217 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
29171 {
29172 1205217 int32_t ctype=cmb->type;
29173
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 1204389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
1205217 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
29174
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 1204389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
1205217 if(custom_spd && (newconveyorclk % rate)) return;
29175
3/4
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 1204542 times.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
1205217 if((cmb->usrflags&cflag5) && HasHeavyBoots())
29176 return;
29177 1205217 is_on_conveyor=false;
29178 1205217 is_conveyor_stunned=0;
29179
29180 1205217 deltax=combo_class_buf[ctype].conveyor_x_speed;
29181 1205217 deltay=combo_class_buf[ctype].conveyor_y_speed;
29182
29183
3/4
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 1204461 times.
✓ Branch 2 taken 756 times.
✗ Branch 3 not taken.
1205217 if (is_conveyor(ctype) && custom_spd)
29184 {
29185 deltax = zslongToFix(cmb->attributes[0]);
29186 deltay = zslongToFix(cmb->attributes[1]);
29187 }
29188
29189
8/8
✓ Branch 0 taken 1204797 times.
✓ Branch 1 taken 420 times.
✓ Branch 2 taken 1204461 times.
✓ Branch 3 taken 336 times.
✓ Branch 4 taken 86205 times.
✓ Branch 5 taken 1118256 times.
✓ Branch 6 taken 42696 times.
✓ Branch 7 taken 43509 times.
1205217 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
29190 {
29191 43509 cmbid = MAPCOMBO(x+8,y+16);
29192 43509 cmb = &combobuf[cmbid];
29193 43509 custom_spd = cmb->usrflags&cflag2;
29194 43509 ctype=(cmb->type);
29195 43509 deltax=combo_class_buf[ctype].conveyor_x_speed;
29196 43509 deltay=combo_class_buf[ctype].conveyor_y_speed;
29197
2/4
✓ Branch 0 taken 43509 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43509 times.
✗ Branch 3 not taken.
43509 if ((deltax != 0 || deltay != 0) && custom_spd)
29198 {
29199 deltax = zslongToFix(cmb->attributes[0]);
29200 deltay = zslongToFix(cmb->attributes[1]);
29201 }
29202 43509 }
29203
29204
4/4
✓ Branch 0 taken 1204797 times.
✓ Branch 1 taken 420 times.
✓ Branch 2 taken 336 times.
✓ Branch 3 taken 1204461 times.
1205217 if(deltax!=0||deltay!=0)
29205 {
29206 756 is_on_conveyor=true;
29207 756 }
29208 1204461 else return;
29209
29210 756 bool movedx = false, movedy = false;
29211
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(cmb->usrflags&cflag4) //Smart corners
29212 {
29213 if(deltay<0)
29214 {
29215 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29216 execute(info);
29217
29218 if(!info.isUnwalkable())
29219 {
29220 movedy = true;
29221 zfix step(0);
29222
29223 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29224 {
29225 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29226 {
29227 yoff=int32_t(y-step)&7;
29228
29229 if(!yoff) break;
29230
29231 step++;
29232 }
29233 }
29234 else
29235 {
29236 step=abs(deltay);
29237 }
29238
29239 y=y-step;
29240 hs_starty-=step.getInt();
29241
29242 for(int32_t j=0; j<chainlinks.Count(); j++)
29243 {
29244 chainlinks.spr(j)->y-=step;
29245 }
29246
29247 if(Lwpns.idFirst(wHookshot)>-1)
29248 {
29249 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29250 }
29251
29252 if(Lwpns.idFirst(wHSHandle)>-1)
29253 {
29254 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29255 }
29256 }
29257 }
29258 else if(deltay>0)
29259 {
29260 info = walkflag(x,y+15+2,2,down);
29261 execute(info);
29262
29263 if(!info.isUnwalkable())
29264 {
29265 movedy = true;
29266 zfix step(0);
29267
29268 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29269 {
29270 while(step<abs(deltay))
29271 {
29272 yoff=int32_t(y+step)&7;
29273
29274 if(!yoff) break;
29275
29276 step++;
29277 }
29278 }
29279 else
29280 {
29281 step=abs(deltay);
29282 }
29283
29284 y=y+step;
29285 hs_starty+=step.getInt();
29286
29287 for(int32_t j=0; j<chainlinks.Count(); j++)
29288 {
29289 chainlinks.spr(j)->y+=step;
29290 }
29291
29292 if(Lwpns.idFirst(wHookshot)>-1)
29293 {
29294 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29295 }
29296
29297 if(Lwpns.idFirst(wHSHandle)>-1)
29298 {
29299 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29300 }
29301 }
29302 }
29303
29304 if(deltax<0)
29305 {
29306 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29307 execute(info);
29308
29309 if(!info.isUnwalkable())
29310 {
29311 movedx = true;
29312 zfix step(0);
29313
29314 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29315 {
29316 while(step<abs(deltax))
29317 {
29318 xoff=int32_t(x-step)&7;
29319
29320 if(!xoff) break;
29321
29322 step++;
29323 }
29324 }
29325 else
29326 {
29327 step=abs(deltax);
29328 }
29329
29330 x=x-step;
29331 hs_startx-=step.getInt();
29332
29333 for(int32_t j=0; j<chainlinks.Count(); j++)
29334 {
29335 chainlinks.spr(j)->x-=step;
29336 }
29337
29338 if(Lwpns.idFirst(wHookshot)>-1)
29339 {
29340 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29341 }
29342
29343 if(Lwpns.idFirst(wHSHandle)>-1)
29344 {
29345 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29346 }
29347 }
29348 }
29349 else if(deltax>0)
29350 {
29351 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29352 execute(info);
29353
29354 if(!info.isUnwalkable())
29355 {
29356 movedx = true;
29357 zfix step(0);
29358
29359 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29360 {
29361 while(step<abs(deltax))
29362 {
29363 xoff=int32_t(x+step)&7;
29364
29365 if(!xoff) break;
29366
29367 step++;
29368 }
29369 }
29370 else
29371 {
29372 step=abs(deltax);
29373 }
29374
29375 x=x+step;
29376 hs_startx+=step.getInt();
29377
29378 for(int32_t j=0; j<chainlinks.Count(); j++)
29379 {
29380 chainlinks.spr(j)->x+=step;
29381 }
29382
29383 if(Lwpns.idFirst(wHookshot)>-1)
29384 {
29385 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29386 }
29387
29388 if(Lwpns.idFirst(wHSHandle)>-1)
29389 {
29390 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29391 }
29392 }
29393 }
29394 if(deltax && !movedx)
29395 y = COMBOY(pos);
29396 if(deltay && !movedy)
29397 x = COMBOX(pos);
29398 }
29399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!movedy)
29400 {
29401
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 681 times.
756 if(deltay<0)
29402 {
29403 75 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29404 75 execute(info);
29405
29406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(!info.isUnwalkable())
29407 {
29408 75 movedy = true;
29409 75 zfix step(0);
29410
29411
9/10
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
75 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29412 {
29413
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29414 {
29415 4 yoff=int32_t(y-step)&7;
29416
29417
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!yoff) break;
29418
29419 4 step++;
29420 }
29421 2 }
29422 else
29423 {
29424 73 step=abs(deltay);
29425 }
29426
29427 75 y=y-step;
29428 75 hs_starty-=step.getInt();
29429
29430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 for(int32_t j=0; j<chainlinks.Count(); j++)
29431 {
29432 chainlinks.spr(j)->y-=step;
29433 }
29434
29435
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(Lwpns.idFirst(wHookshot)>-1)
29436 {
29437 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29438 }
29439
29440
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(Lwpns.idFirst(wHSHandle)>-1)
29441 {
29442 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29443 }
29444 75 }
29445 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
29446 75 }
29447
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 261 times.
681 else if(deltay>0)
29448 {
29449 261 info = walkflag(x,y+15+2,2,down);
29450 261 execute(info);
29451
29452
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 156 times.
261 if(!info.isUnwalkable())
29453 {
29454 156 movedy = true;
29455 156 zfix step(0);
29456
29457
8/10
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 22 times.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 16 times.
156 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29458 {
29459
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 28 times.
40 while(step<abs(deltay))
29460 {
29461 28 yoff=int32_t(y+step)&7;
29462
29463
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 4 times.
28 if(!yoff) break;
29464
29465 24 step++;
29466 }
29467 16 }
29468 else
29469 {
29470 140 step=abs(deltay);
29471 }
29472
29473 156 y=y+step;
29474 156 hs_starty+=step.getInt();
29475
29476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 for(int32_t j=0; j<chainlinks.Count(); j++)
29477 {
29478 chainlinks.spr(j)->y+=step;
29479 }
29480
29481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(Lwpns.idFirst(wHookshot)>-1)
29482 {
29483 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29484 }
29485
29486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(Lwpns.idFirst(wHSHandle)>-1)
29487 {
29488 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29489 }
29490 156 }
29491 105 else checkdamagecombos(x,y+15);
29492 261 }
29493 756 }
29494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!movedx)
29495 {
29496
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 502 times.
756 if(deltax<0)
29497 {
29498 254 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29499 254 execute(info);
29500
29501
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 204 times.
254 if(!info.isUnwalkable())
29502 {
29503 204 movedx = true;
29504 204 zfix step(0);
29505
29506
8/10
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 180 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
204 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29507 {
29508
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 10 times.
15 while(step<abs(deltax))
29509 {
29510 10 xoff=int32_t(x-step)&7;
29511
29512
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!xoff) break;
29513
29514 10 step++;
29515 }
29516 5 }
29517 else
29518 {
29519 199 step=abs(deltax);
29520 }
29521
29522 204 x=x-step;
29523 204 hs_startx-=step.getInt();
29524
29525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 for(int32_t j=0; j<chainlinks.Count(); j++)
29526 {
29527 chainlinks.spr(j)->x-=step;
29528 }
29529
29530
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(Lwpns.idFirst(wHookshot)>-1)
29531 {
29532 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29533 }
29534
29535
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(Lwpns.idFirst(wHSHandle)>-1)
29536 {
29537 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29538 }
29539 204 }
29540 50 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
29541 254 }
29542
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 166 times.
502 else if(deltax>0)
29543 {
29544 166 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29545 166 execute(info);
29546
29547
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 164 times.
166 if(!info.isUnwalkable())
29548 {
29549 164 movedx = true;
29550 164 zfix step(0);
29551
29552
8/10
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
164 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29553 {
29554
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 27 times.
39 while(step<abs(deltax))
29555 {
29556 27 xoff=int32_t(x+step)&7;
29557
29558
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!xoff) break;
29559
29560 25 step++;
29561 }
29562 14 }
29563 else
29564 {
29565 150 step=abs(deltax);
29566 }
29567
29568 164 x=x+step;
29569 164 hs_startx+=step.getInt();
29570
29571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 for(int32_t j=0; j<chainlinks.Count(); j++)
29572 {
29573 chainlinks.spr(j)->x+=step;
29574 }
29575
29576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 if(Lwpns.idFirst(wHookshot)>-1)
29577 {
29578 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29579 }
29580
29581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 if(Lwpns.idFirst(wHSHandle)>-1)
29582 {
29583 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29584 }
29585 164 }
29586 2 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
29587 166 }
29588 756 }
29589
4/4
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 157 times.
756 if(movedx || movedy)
29590 {
29591
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 if(cmb->usrflags&cflag1)
29592 is_conveyor_stunned = rate;
29593
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 if(cmb->usrflags&cflag3)
29594 {
29595 if(abs(deltax) > abs(deltay))
29596 dir = (deltax > 0) ? right : left;
29597 else dir = (deltay > 0) ? down : up;
29598 }
29599 599 }
29600 756 }
29601 3628643 }
29602
29603 void HeroClass::setNayrusLoveShieldClk(int32_t newclk)
29604 {
29605 NayrusLoveShieldClk=newclk;
29606
29607 if(decorations.idCount(dNAYRUSLOVESHIELD)==0)
29608 {
29609 decoration *dec;
29610 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29611 decorations.spr(decorations.Count()-1)->misc=0;
29612 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29613 dec=(decoration *)decorations.spr(decorations.Count()-1);
29614 decorations.spr(decorations.Count()-1)->misc=1;
29615 }
29616 }
29617
29618 7107 int32_t HeroClass::getNayrusLoveShieldClk()
29619 {
29620 7107 return NayrusLoveShieldClk;
29621 }
29622
29623 int32_t HeroClass::getHoverClk()
29624 {
29625 return hoverclk;
29626 }
29627
29628 5216427 int32_t HeroClass::getHoldClk()
29629 {
29630 5216427 return holdclk;
29631 }
29632
29633 4019845 int32_t HeroClass::getLastLensID(){
29634 4019845 return last_lens_id;
29635 }
29636
29637 208 void HeroClass::setLastLensID(int32_t p_item){
29638 208 last_lens_id = p_item;
29639 208 }
29640
29641 30239536 bool HeroClass::getOnSideviewLadder()
29642 {
29643 30239536 return on_sideview_ladder;
29644 }
29645
29646 71 void HeroClass::setOnSideviewLadder(bool val)
29647 {
29648
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 5 times.
71 if(val)
29649 {
29650 5 fall = fakefall = hoverclk = jumping = 0;
29651 5 hoverflags = 0;
29652 5 inair = false;
29653 5 }
29654 71 on_sideview_ladder = val;
29655 71 }
29656
29657 1080713 bool HeroClass::canSideviewLadder(bool down)
29658 {
29659
2/2
✓ Branch 0 taken 1045074 times.
✓ Branch 1 taken 35639 times.
1080713 if(!isSideViewHero()) return false;
29660
2/2
✓ Branch 0 taken 22433 times.
✓ Branch 1 taken 13206 times.
35639 if(jumping < 0) return false;
29661
3/4
✓ Branch 0 taken 9387 times.
✓ Branch 1 taken 13046 times.
✓ Branch 2 taken 9387 times.
✗ Branch 3 not taken.
22433 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29662 {
29663 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29664 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
29665 }
29666 //Are you presently able to climb a sideview ladder?
29667 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29668 //y+0 checks your top-half for large hitbox; y+8 for small
29669 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29670 //y+16 check is for going down onto a ladder you are standing on.
29671
2/2
✓ Branch 0 taken 22155 times.
✓ Branch 1 taken 278 times.
44517 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
29672
4/4
✓ Branch 0 taken 22084 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 22000 times.
✓ Branch 3 taken 84 times.
22155 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
29673
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22000 times.
✓ Branch 2 taken 12613 times.
✓ Branch 3 taken 9387 times.
✓ Branch 4 taken 9387 times.
✗ Branch 5 not taken.
31387 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
29674 1080713 }
29675
29676 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
29677 {
29678 if(!isSideViewHero()) return false;
29679 if(jumping < 0) return false;
29680 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29681 {
29682 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29683 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
29684 }
29685 //Are you presently able to climb a sideview ladder?
29686 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29687 //y+0 checks your top-half for large hitbox; y+8 for small
29688 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29689 //y+16 check is for going down onto a ladder you are standing on.
29690 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
29691 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
29692 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
29693 }
29694
29695 2276628 void HeroClass::execute(HeroClass::WalkflagInfo info)
29696 {
29697 2276628 int32_t flags = info.getFlags();
29698
29699
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 2276376 times.
2276628 if(flags & WalkflagInfo::CLEARILSWIM)
29700 252 ilswim =false;
29701
2/2
✓ Branch 0 taken 2276173 times.
✓ Branch 1 taken 203 times.
2276376 else if(flags & WalkflagInfo::SETILSWIM)
29702 203 ilswim = true;
29703
29704
1/2
✓ Branch 0 taken 2276628 times.
✗ Branch 1 not taken.
2276628 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
29705 {
29706 charging = 0;
29707 attackclk = 0;
29708 }
29709
29710
1/2
✓ Branch 0 taken 2276628 times.
✗ Branch 1 not taken.
2276628 if(flags & WalkflagInfo::SETDIR)
29711 {
29712 dir = info.getDir();
29713 }
29714
29715
2/2
✓ Branch 0 taken 2276393 times.
✓ Branch 1 taken 235 times.
2276628 if(flags & WalkflagInfo::SETHOPCLK)
29716 {
29717 235 hopclk = info.getHopClk();
29718 235 }
29719
29720
2/2
✓ Branch 0 taken 2276510 times.
✓ Branch 1 taken 118 times.
2276628 if(flags & WalkflagInfo::SETHOPDIR)
29721 {
29722 118 hopdir = info.getHopDir();
29723 118 }
29724
29725 2276628 }
29726
29727 4617196 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
29728 {
29729 4617196 HeroClass::WalkflagInfo ret;
29730 4617196 ret.newhopclk = newhopclk;
29731 4617196 ret.newdir = newdir;
29732
2/2
✓ Branch 0 taken 3803027 times.
✓ Branch 1 taken 814169 times.
4617196 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29733
29734 4617196 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
29735 4617196 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
29736 4617196 ret.flags = flags1 | flags2;
29737 4617196 return ret;
29738 }
29739
29740 29912 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
29741 {
29742 29912 HeroClass::WalkflagInfo ret;
29743 29912 ret.newhopclk = newhopclk;
29744 29912 ret.newdir = newdir;
29745
1/2
✓ Branch 0 taken 29912 times.
✗ Branch 1 not taken.
29912 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29746
29747 29912 ret.flags = flags & other.flags;
29748 29912 return ret;
29749 }
29750
29751 29912 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
29752 {
29753 29912 HeroClass::WalkflagInfo ret;
29754 29912 ret.newhopclk = newhopclk;
29755 29912 ret.newdir = newdir;
29756 29912 ret.newhopdir = newhopdir;
29757
29758 29912 ret.flags = flags ^ UNWALKABLE;
29759 29912 return ret;
29760 }
29761
29762 void HeroClass::explode(int32_t type)
29763 {
29764 static int32_t tempx, tempy;
29765 static byte herotilebuf[256];
29766 int32_t ltile=0;
29767 int32_t lflip=0;
29768 bool shieldModify=true;
29769 unpack_tile(newtilebuf, tile, flip, true);
29770 memcpy(herotilebuf, unpackbuf, 256);
29771 tempx=Hero.getX();
29772 tempy=Hero.getY();
29773 for(int32_t i=0; i<16; ++i)
29774 {
29775 for(int32_t j=0; j<16; ++j)
29776 {
29777 if(herotilebuf[i*16+j])
29778 {
29779 if(type==0) // Twilight
29780 {
29781 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
29782 int32_t k=particles.Count()-1;
29783 particle *p = (particles.at(k));
29784 p->step=3;
29785 }
29786 else if(type ==1) // Sands of Hours
29787 {
29788 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
29789 int32_t k=particles.Count()-1;
29790 particle *p = (particles.at(k));
29791 p->step=4;
29792
29793 if(zc_oldrand()%10 < 2)
29794 {
29795 p->color=1;
29796 p->cset=0;
29797 }
29798 }
29799 else
29800 {
29801 particles.add(new pFaroresWindDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
29802
29803 int32_t k=particles.Count()-1;
29804 particle *p = (particles.at(k));
29805 p->angular=true;
29806 p->angle=zc_oldrand();
29807 p->step=(((double)j)/8);
29808 p->yofs=Hero.getYOfs();
29809 }
29810 }
29811 }
29812 }
29813 }
29814
29815 463 void HeroClass::SetSwim()
29816 {
29817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if (CanSideSwim())
29818 {
29819 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
29820 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29821 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
29822 }
29823 463 else {action=swimming; FFCore.setHeroAction(swimming);}
29824 463 }
29825
29826 41269 void HeroClass::SetAttack()
29827 {
29828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41269 times.
41269 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29829 41269 else {action=attacking; FFCore.setHeroAction(attacking);}
29830 41269 }
29831
29832 30234146 bool HeroClass::IsSideSwim()
29833 {
29834
6/12
✓ Branch 0 taken 30234146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30234146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30234146 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30234146 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 30234146 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 30234146 times.
30234146 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
29835 }
29836
29837 680615 bool HeroClass::CanSideSwim()
29838 {
29839
1/2
✓ Branch 0 taken 680615 times.
✗ Branch 1 not taken.
680615 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
29840 }
29841
29842 2894221 int32_t HeroClass::getTileModifier()
29843 {
29844 2894221 return item_tile_mod() + bunny_tile_mod();
29845 }
29846 void HeroClass::setImmortal(int32_t nimmortal)
29847 {
29848 immortal = nimmortal;
29849 }
29850 void HeroClass::kill(bool bypassFairy)
29851 {
29852 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
29853 }
29854 7274652 bool HeroClass::sideview_mode() const
29855 {
29856
3/4
✓ Branch 0 taken 522397 times.
✓ Branch 1 taken 6752255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 522397 times.
7274652 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
29857 }
29858 13071 bool HeroClass::is_unpushable() const
29859 {
29860 13071 return toogam;
29861 }
29862 /*** end of hero.cpp ***/
29863
29864
29865
29866
29867